summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChoe Hwanjin <choe.hwanjin@gmail.com>2018-06-05 12:29:02 +0900
committerChoe Hwanjin <choe.hwanjin@gmail.com>2018-06-05 12:29:02 +0900
commite97db746cc84f9338eb60b0aa60c3b22a0aea04a (patch)
tree6854b8dcec3ef787d7aefb6db2b3fa312146afd9
parent2222deef90efd70dbe4800317211f3c18d403923 (diff)
downloadlibhangul-e97db746cc84f9338eb60b0aa60c3b22a0aea04a.tar.gz
키보드 파일을 로딩시 재귀호출 테스트 코드 추가
키보드 파일이 자기자신을 include한 경우에대한 테스트 코드 추가한다. 관련 api hangul_keyboard_new_from_file()도 추가하고 샘플 키보드 파일 recursive.xml을 추가한다.
-rw-r--r--hangul/hangul.h1
-rw-r--r--hangul/hangulkeyboard.c2
-rw-r--r--test/Makefile.am4
-rw-r--r--test/recursive.xml12
-rw-r--r--test/test.c6
5 files changed, 22 insertions, 3 deletions
diff --git a/hangul/hangul.h b/hangul/hangul.h
index 447e1e3..61d4357 100644
--- a/hangul/hangul.h
+++ b/hangul/hangul.h
@@ -101,6 +101,7 @@ int hangul_fini();
/* keyboard */
HangulKeyboard* hangul_keyboard_new(void);
+HangulKeyboard* hangul_keyboard_new_from_file(const char* path);
void hangul_keyboard_delete(HangulKeyboard *keyboard);
void hangul_keyboard_set_type(HangulKeyboard *keyboard, int type);
diff --git a/hangul/hangulkeyboard.c b/hangul/hangulkeyboard.c
index caaae29..c04a417 100644
--- a/hangul/hangulkeyboard.c
+++ b/hangul/hangulkeyboard.c
@@ -767,7 +767,7 @@ done:
context->path_stack_top--;
}
-static HangulKeyboard*
+HangulKeyboard*
hangul_keyboard_new_from_file(const char* path)
{
HangulKeyboardLoadContext context;
diff --git a/test/Makefile.am b/test/Makefile.am
index 5889f49..6364f50 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -12,5 +12,5 @@ hanja_LDADD = ../hangul/libhangul.la $(LTLIBINTL)
TESTS = test
check_PROGRAMS = test
test_SOURCES = test.c ../hangul/hangul.h
-test_CFLAGS = $(CHECK_CFLAGS)
-test_LDADD = $(CHECK_LIBS) $(top_builddir)/hangul/libhangul.la $(LTLIBINTL)
+test_CFLAGS = $(CHECK_CFLAGS) -DTEST_SOURCE_DIR=\"$(abs_srcdir)\"
+test_LDADD = $(CHECK_LIBS) ../hangul/libhangul.la $(LTLIBINTL)
diff --git a/test/recursive.xml b/test/recursive.xml
new file mode 100644
index 0000000..cd2ab15
--- /dev/null
+++ b/test/recursive.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<hangul-keyboard id="recursive" type="jamo">
+
+ <name>Recursive</name>
+
+ <map id="0">
+ <item key="0x20" value="0x0020"/>
+ </map>
+
+ <include file="recursive.xml"/>
+
+</hangul-keyboard>
diff --git a/test/test.c b/test/test.c
index 3147ee5..579b5e1 100644
--- a/test/test.c
+++ b/test/test.c
@@ -543,6 +543,12 @@ START_TEST(test_hangul_keyboard)
fail_unless(name != NULL,
"error: keyboard id == NULL");
}
+
+ HangulKeyboard* keyboard;
+ fail_unless(
+ (keyboard = hangul_keyboard_new_from_file(TEST_SOURCE_DIR "/recursive.xml")) != NULL
+ );
+ hangul_keyboard_delete(keyboard);
}
END_TEST