Skip to content

Commit

Permalink
fix build errors with check
Browse files Browse the repository at this point in the history
  • Loading branch information
Badoum92 authored and Snaipe committed Jan 5, 2022
1 parent 5bc7aad commit ac73451
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 41 deletions.
15 changes: 8 additions & 7 deletions check/test/array.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,11 @@ START_TEST (test_array_dtor_run_with_meta) {
ck_assert_msg(dtor_run, "Expected destructor to run");
} END_TEST

TFun array_tests[] = {
test_array,
test_array_meta,
test_array_dtor_run,
test_array_dtor_run_with_meta,
NULL
};
TCase *make_array_tests(void) {
TCase *tc = tcase_create("array");
tcase_add_test(tc, test_array);
tcase_add_test(tc, test_array_meta);
tcase_add_test(tc, test_array_dtor_run);
tcase_add_test(tc, test_array_dtor_run_with_meta);
return tc;
}
11 changes: 6 additions & 5 deletions check/test/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ START_TEST (test_alloc_failure) {
} END_TEST
#endif

TFun misc_tests[] = {
TCase *make_misc_tests(void) {
TCase *tc = tcase_create("misc");
#ifndef SMALLOC_FIXED_ALLOCATOR
test_alloc_failure,
tcase_add_test(tc, test_alloc_failure);
#endif
test_zero_size,
NULL
};
tcase_add_test(tc, test_zero_size);
return tc;
}
16 changes: 8 additions & 8 deletions check/test/scalar.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ START_TEST (test_dtor_run_with_meta) {
ck_assert_msg(dtor_run, "Expected destructor to run");
} END_TEST

TFun scalar_tests[] = {
test_pointer_valid,
test_meta,
test_dtor_run,
test_dtor_run_with_meta,
NULL
};

TCase *make_scalar_tests(void) {
TCase *tc = tcase_create("scalar");
tcase_add_test(tc, test_pointer_valid);
tcase_add_test(tc, test_meta);
tcase_add_test(tc, test_dtor_run);
tcase_add_test(tc, test_dtor_run_with_meta);
return tc;
}
11 changes: 6 additions & 5 deletions check/test/shared.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ START_TEST (test_shared_sref) {
ck_assert_msg(dtor_run == 0, "Expected destructor NOT to have run.");
} END_TEST

TFun shared_tests[] = {
test_shared_init,
test_shared_sref,
NULL
};
TCase *make_shared_tests(void) {
TCase *tc = tcase_create("shared");
tcase_add_test(tc, test_shared_init);
tcase_add_test(tc, test_shared_sref);
return tc;
}
8 changes: 4 additions & 4 deletions check/test/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ const struct meta m = {1, 2, 3};

Suite *master_suite(void) {
Suite *s = suite_create("master");
suite_add_tcase(s, make_test_case("misc", misc_tests));
suite_add_tcase(s, make_test_case("scalar", scalar_tests));
suite_add_tcase(s, make_test_case("array", array_tests));
suite_add_tcase(s, make_test_case("shared", shared_tests));
suite_add_tcase(s, make_misc_tests());
suite_add_tcase(s, make_scalar_tests());
suite_add_tcase(s, make_array_tests());
suite_add_tcase(s, make_shared_tests());
return s;
}

Expand Down
8 changes: 4 additions & 4 deletions check/test/test.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

Suite *unique_ptr_suite(void);

extern TFun scalar_tests[];
extern TFun array_tests[];
extern TFun misc_tests[];
extern TFun shared_tests[];
TCase *make_scalar_tests(void);
TCase *make_array_tests(void);
TCase *make_misc_tests(void);
TCase *make_shared_tests(void);

#endif /* !TEST_H_ */
8 changes: 0 additions & 8 deletions check/test/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@ inline void assert_valid_ptr(void *ptr) {
"Expected unique_ptr to return an aligned pointer.");
}

__attribute__((always_inline))
inline TCase *make_test_case(const char *name, TFun func[]) {
TCase *tc = tcase_create(name);
for (TFun *f = func; *f != NULL; ++f)
tcase_add_test(tc, *f);
return tc;
}

struct meta {
int i;
long l;
Expand Down

0 comments on commit ac73451

Please sign in to comment.