END_TEST START_TEST(test_hangul_keyboard) { const char* id; const char* name; unsigned int n; unsigned int i; n = hangul_keyboard_list_get_count(); fail_unless(n != 0, "error: there is no hangul keyboard"); for (i = 0; i < n; ++i) { id = hangul_keyboard_list_get_keyboard_id(i); fail_unless(id != NULL, "error: keyboard id == NULL"); } for (i = 0; i < n; ++i) { name = hangul_keyboard_list_get_keyboard_name(i); fail_unless(name != NULL, "error: keyboard id == NULL"); } HangulKeyboard* keyboard; fail_unless( (keyboard = hangul_keyboard_new_from_file(TEST_SOURCE_DIR "/recursive.xml")) != NULL ); fail_unless( (id = hangul_keyboard_list_register_keyboard(keyboard)) != NULL ); fail_unless( strcmp(id, "recursive") == 0 ); fail_unless( hangul_keyboard_list_get_count() == n + 1 ); fail_unless( hangul_keyboard_list_get_keyboard(id) == keyboard ); fail_unless( hangul_keyboard_list_unregister_keyboard(id) == keyboard ); hangul_keyboard_delete(keyboard); }
static unsigned hangul_keyboard_list_load_dir(const char* path) { char pattern[PATH_MAX]; snprintf(pattern, sizeof(pattern), "%s/*.xml", path); glob_t result; int res = glob(pattern, GLOB_ERR, NULL, &result); if (res != 0) return 0; size_t i; for (i = 0; i < result.gl_pathc; ++i) { HangulKeyboard* keyboard = hangul_keyboard_new_from_file(result.gl_pathv[i]); if (keyboard == NULL) continue; hangul_keyboard_list_append(keyboard); } globfree(&result); return hangul_keyboards.n; }