extern boolean is_include_file (const char *const fileName) { boolean result = TRUE; const char *const extension = file_get_extension (fileName); result = strcasecmp(extension,"h"); return !result; }
} 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, NULL); } END_TEST
/** * returns 1 if a given file is a p12 token, otherwise 0 */ static int is_token(const char *path, const char *file, UNUSED void *data) { char *location = mem_printf("%s/%s", path, file); char *ext; // regular file if (!file_is_regular(location)) return 0; // with fixed extesion if (!(ext = file_get_extension(file))) return 0; if (!strncmp(ext, TOKEN_DEFAULT_EXT, strlen(TOKEN_DEFAULT_EXT))) { DEBUG("Found token file: %s", location); mem_free(location); return 1; } mem_free(location); return 0; }
} END_TEST START_TEST(test_file_get_extension_none) { const char* path = "test"; fail_unless(file_get_extension(path) == NULL, NULL); } END_TEST