diff --git a/tests/test_document.c b/tests/test_document.c new file mode 100644 index 0000000..f5dfd52 --- /dev/null +++ b/tests/test_document.c @@ -0,0 +1,24 @@ +/* See LICENSE file for license and copyright information */ + +#include + +#include "../document.h" + +START_TEST(test_open) { + fail_unless(zathura_document_open(NULL, NULL, NULL) == NULL, "Could create document", NULL); + fail_unless(zathura_document_open(NULL, "fl", NULL) == NULL, "Could create document", NULL); + fail_unless(zathura_document_open(NULL, "fl", "pw") == NULL, "Could create document", NULL); +} END_TEST + +Suite* suite_document() +{ + TCase* tcase = NULL; + Suite* suite = suite_create("Document"); + + /* basic */ + tcase = tcase_create("basic"); + tcase_add_test(tcase, test_open); + suite_add_tcase(suite, tcase); + + return suite; +} diff --git a/tests/tests.c b/tests/tests.c index 1f21807..5e3098f 100644 --- a/tests/tests.c +++ b/tests/tests.c @@ -4,8 +4,19 @@ #include #include -Suite* suite_session(); -Suite* suite_utils(); +#define LENGTH(x) (sizeof(x)/sizeof((x)[0])) + +extern Suite* suite_session(); +extern Suite* suite_utils(); +extern Suite* suite_document(); + +typedef Suite* (*suite_create_fnt_t)(void); + +const suite_create_fnt_t suites[] = { + suite_utils, + suite_document, + suite_session, +}; int main(int argc, char* argv[]) @@ -17,19 +28,14 @@ main(int argc, char* argv[]) /* init gtk */ gtk_init(&argc, &argv); - /* test session */ - suite = suite_session(); - suite_runner = srunner_create(suite); - srunner_run_all(suite_runner, CK_NORMAL); - number_failed += srunner_ntests_failed(suite_runner); - srunner_free(suite_runner); - - /* test utils */ - suite = suite_utils(); - suite_runner = srunner_create(suite); - srunner_run_all(suite_runner, CK_NORMAL); - number_failed += srunner_ntests_failed(suite_runner); - srunner_free(suite_runner); + /* run test suites */ + for (unsigned int i = 0; i < LENGTH(suites); i++) { + suite = suites[i](); + suite_runner = srunner_create(suite); + srunner_run_all(suite_runner, CK_NORMAL); + number_failed += srunner_ntests_failed(suite_runner); + srunner_free(suite_runner); + } return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; }