mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
config: add unit test for config_clone()
We’re mainly interested in seeing that we don’t leak memory, or double free heap allocated data. Valgrind and/or gcc/clang sanitizers are best at this, hence the very few asserts in the test itself.
This commit is contained in:
parent
88fb8429b0
commit
55bd3cfd62
1 changed files with 21 additions and 0 deletions
21
config.c
21
config.c
|
|
@ -3140,6 +3140,27 @@ config_clone(const struct config *old)
|
|||
return conf;
|
||||
}
|
||||
|
||||
UNITTEST
|
||||
{
|
||||
struct config original;
|
||||
user_notifications_t nots = tll_init();
|
||||
config_override_t overrides = tll_init();
|
||||
|
||||
bool ret = config_load(&original, "/dev/null", ¬s, &overrides, false);
|
||||
xassert(ret);
|
||||
|
||||
struct config *clone = config_clone(&original);
|
||||
xassert(clone != NULL);
|
||||
xassert(clone != &original);
|
||||
|
||||
config_free(original);
|
||||
config_free(*clone);
|
||||
free(clone);
|
||||
|
||||
tll_free(overrides);
|
||||
tll_free(nots);
|
||||
}
|
||||
|
||||
void
|
||||
config_free(struct config conf)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue