Added file_get_extension test cases

This commit is contained in:
Moritz Lipp 2012-01-28 20:14:21 +01:00
parent 8ddbb158e3
commit 29472cdd06
2 changed files with 15 additions and 2 deletions

View file

@ -21,7 +21,7 @@ endif
all: options ${PROJECT} run all: options ${PROJECT} run
run: run: ${PROJECT}
$(QUIET)./${PROJECT} $(QUIET)./${PROJECT}
options: options:

View file

@ -9,7 +9,18 @@ START_TEST(test_file_exists_null) {
} END_TEST } END_TEST
START_TEST(test_file_get_extension_null) { START_TEST(test_file_get_extension_null) {
fail_unless(file_get_extension(NULL) == false); fail_unless(file_get_extension(NULL) == NULL);
} END_TEST
START_TEST(test_file_get_extension_none) {
const char* path = "test";
fail_unless(file_get_extension(path) == NULL);
} END_TEST
START_TEST(test_file_get_extension_single) {
const char* path = "test.pdf";
const char* extension = file_get_extension(path);
fail_unless(strcmp(extension, "pdf") == 0);
} END_TEST } END_TEST
Suite* suite_utils() Suite* suite_utils()
@ -25,6 +36,8 @@ Suite* suite_utils()
/* file exists */ /* file exists */
tcase = tcase_create("file_get_extension"); tcase = tcase_create("file_get_extension");
tcase_add_test(tcase, test_file_get_extension_null); tcase_add_test(tcase, test_file_get_extension_null);
tcase_add_test(tcase, test_file_get_extension_none);
tcase_add_test(tcase, test_file_get_extension_single);
suite_add_tcase(suite, tcase); suite_add_tcase(suite, tcase);
return suite; return suite;