[aquaskk-changes 350] CVS update: AquaSKK/src/test

Back to archive index

t-suw****@users***** t-suw****@users*****
2007年 8月 26日 (日) 01:34:45 JST


Index: AquaSKK/src/test/Makefile
diff -u /dev/null AquaSKK/src/test/Makefile:1.1.2.1
--- /dev/null	Sun Aug 26 01:34:45 2007
+++ AquaSKK/src/test/Makefile	Sun Aug 26 01:34:45 2007
@@ -0,0 +1,35 @@
+###
+### unit test
+###
+
+VPATH	= $(shell find .. -type d -a ! -name CVS -a ! -name test -a ! -name ..) ../..
+CXXFLAGS= -g $(foreach dir,$(VPATH),-I$(dir))
+
+TARGET	= SKKKeymapEntry_TEST SKKKeymap_TEST
+
+define BUILD_template
+$(1): $(1).o
+	$(CXX) -o $(1) $(1).o
+endef
+
+all: build
+
+$(foreach prog,$(TARGET),$(eval $(call BUILD_template,$(prog))))
+
+build: $(TARGET)
+
+###
+### rule
+###
+clean:
+	$(RM) $(TARGET) *.o
+
+test: build
+	for i in $(TARGET); do ./$$i; done
+
+###
+### dependencies
+###
+
+SKKKeymapEntry_TEST.o: SKKKeymapEntry_TEST.cpp SKKKeymapEntry.cpp SKKKeymapEntry.h
+SKKKeymap_TEST.o: SKKKeymap_TEST.cpp SKKKeymapEntry.cpp SKKKeymapEntry.h SKKKeymap.cpp SKKKeymap.h
Index: AquaSKK/src/test/SKKKeymapEntry_TEST.cpp
diff -u /dev/null AquaSKK/src/test/SKKKeymapEntry_TEST.cpp:1.1.2.1
--- /dev/null	Sun Aug 26 01:34:45 2007
+++ AquaSKK/src/test/SKKKeymapEntry_TEST.cpp	Sun Aug 26 01:34:45 2007
@@ -0,0 +1,43 @@
+#include "SKKKeyState.h"
+#include "SKKKeymapEntry.cpp"
+#include <iostream>
+
+int main() {
+    SKKKeymapEntry entry;
+    int key;
+
+    entry = SKKKeymapEntry("Unknown", "a");
+    assert(!(entry >> key));
+
+    entry = SKKKeymapEntry("SKK_JMODE", "a");
+    entry >> key;
+    assert(key == SKKKeyState::Ascii('a', false));
+    assert(entry.Symbol() == SKK_JMODE);
+    assert(!(entry >> key));
+
+    entry = SKKKeymapEntry("SKK_JMODE", "keycode::0x0a");
+    entry >> key;
+    assert(key == SKKKeyState::Keycode(0x0a, false));
+
+    entry = SKKKeymapEntry("SKK_ENTER", "hex::0x03");
+    entry >> key;
+    assert(key == SKKKeyState::Ascii(0x03, false));
+
+    entry = SKKKeymapEntry("SKK_ENTER", "ctrl::m");
+    entry >> key;
+    assert(key == SKKKeyState::Ascii('m', true));
+
+    entry = SKKKeymapEntry("Direct", "group::a,c,d-f");
+    assert(!entry.IsEvent());
+    assert(entry.Symbol() == Direct);
+    entry >> key;
+    assert(key == SKKKeyState::Ascii('a', false));
+    entry >> key;
+    assert(key == SKKKeyState::Ascii('c', false));
+    entry >> key;
+    assert(key == SKKKeyState::Ascii('d', false));
+    entry >> key;
+    assert(key == SKKKeyState::Ascii('e', false));
+    entry >> key;
+    assert(key == SKKKeyState::Ascii('f', false));
+}
Index: AquaSKK/src/test/SKKKeymap_TEST.cpp
diff -u /dev/null AquaSKK/src/test/SKKKeymap_TEST.cpp:1.1.2.1
--- /dev/null	Sun Aug 26 01:34:45 2007
+++ AquaSKK/src/test/SKKKeymap_TEST.cpp	Sun Aug 26 01:34:45 2007
@@ -0,0 +1,37 @@
+#include <iostream>
+#include "SKKKeymap.cpp"
+#include "SKKKeymapEntry.cpp"
+
+int main() {
+    SKKKeymap keymap;
+    SKKEventParam param;
+
+    keymap.Initialize("../keybindings/keymap.conf");
+
+    assert(keymap.Fetch(0, 0, 0) == SKKEventParam(SKK_CHAR, 0, 0));
+    assert(keymap.Fetch('j', 0, true) == SKKEventParam(SKK_JMODE, 'j', 0));
+    assert(keymap.Fetch(0x03, 0, 0) == SKKEventParam(SKK_ENTER, 0x03, 0));
+    assert(keymap.Fetch(0x09, 0, 0) == SKKEventParam(SKK_TAB, 0x09, 0));
+    assert(keymap.Fetch('i', 0, true) == SKKEventParam(SKK_TAB, 'i', 0));
+    assert(keymap.Fetch('g', 0, true) == SKKEventParam(SKK_CANCEL, 'g', 0));
+    assert(keymap.Fetch(0x1c, 0, 0) == SKKEventParam(SKK_LEFT, 0x1c, 0));
+
+    param = keymap.Fetch('b', 0, 0);
+    assert(param == SKKEventParam(SKK_CHAR, 'b', None));
+
+    param = keymap.Fetch('q', 0, 0);
+    assert(param == SKKEventParam(SKK_CHAR, 'q', ToggleKana));
+
+    param = keymap.Fetch('q', 0, true);
+    assert(param == SKKEventParam(SKK_CHAR, 'q', ToggleJisx0201Kana));
+
+    param = keymap.Fetch('A', 0, 0);
+    assert(param == SKKEventParam(SKK_CHAR, 'A', UpperCases));
+
+    param = keymap.Fetch('1', 0x51, 0);
+    assert(param == SKKEventParam(SKK_CHAR, '1', Direct));
+
+    param = keymap.Fetch('f', 0, true);
+    assert(param == SKKEventParam(SKK_RIGHT, 'f', 0));
+    std::cerr << param.dump() << std::endl;
+}


aquaskk-changes メーリングリストの案内
Back to archive index