Begin document test case

This commit is contained in:
Moritz Lipp 2012-03-30 16:43:00 +02:00
parent 9cdd963784
commit 2340590e93
2 changed files with 45 additions and 15 deletions

24
tests/test_document.c Normal file
View file

@ -0,0 +1,24 @@
/* See LICENSE file for license and copyright information */
#include <check.h>
#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;
}

View file

@ -4,8 +4,19 @@
#include <stdlib.h>
#include <gtk/gtk.h>
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;
}