#include "../src/set.c" #include "../src/testing.h" static int test_set_new(void) { int rc = -1; const struct Set *s = NULL; test_start("set_new()"); { testing("simple allocation"); const size_t size = sizeof(long long); if (set_new(size, &s)) { logerr("set_new()"); goto out; } assert(s->value_size == size); set_free(&s); test_ok(); } rc = 0; out: if (s != NULL) { set_free(&s); } return rc; } static int test_set_free(void) { int rc = -1; const struct Set *s = NULL; test_start("set_free()"); { testing("*s becomes NULL again after set_free(&s)"); assert(s == NULL); if (set_new(1U, &s)) { logerr("set_new()"); goto out; } assert(s != NULL); set_free(&s); assert(s == NULL); test_ok(); } rc = 0; out: if (s != NULL) { set_free(&s); } return rc; } int main(void) { int rc = EXIT_FAILURE; if (test_set_new()) { logerr("test_set_new()"); goto out; } if (test_set_free()) { logerr("test_set_free()"); goto out; } rc = EXIT_SUCCESS; out: return rc; }