[aquaskk-changes 280] CVS update: AquaSKK/tests

Back to archive index

Tomotaka SUWA t-suw****@users*****
2006年 12月 29日 (金) 09:50:16 JST


Index: AquaSKK/tests/Makefile
diff -u /dev/null AquaSKK/tests/Makefile:1.1
--- /dev/null	Fri Dec 29 09:50:16 2006
+++ AquaSKK/tests/Makefile	Fri Dec 29 09:50:16 2006
@@ -0,0 +1,31 @@
+# $Id: Makefile,v 1.1 2006/12/29 00:50:16 t-suwa Exp $
+
+#
+# Makefile for Unit Test
+#
+
+TARGET	= SKKCandidateTEST SKKOkuriHintTEST SKKEntryTEST
+CXXFLAGS= -I.. -g
+
+all: $(TARGET)
+
+check: all
+	for i in $(TARGET); do ./$$i; done;
+
+clean:
+	rm -f *.o $(TARGET)
+
+###
+### for Dictionary.h
+###
+
+SKKCandidateTEST: SKKCandidateTEST.o
+	$(CXX) -o $@ $<
+
+SKKOkuriHintTEST: SKKOkuriHintTEST.o
+	$(CXX) -o $@ $<
+
+SKKEntryTEST: SKKEntryTEST.o
+	$(CXX) -o $@ $<
+
+SKKCandidateTEST.o SKKOkuriHintTEST.o SKKEntryTEST.o: ../Dictionary.h
Index: AquaSKK/tests/SKKCandidateTEST.cpp
diff -u /dev/null AquaSKK/tests/SKKCandidateTEST.cpp:1.1
--- /dev/null	Fri Dec 29 09:50:16 2006
+++ AquaSKK/tests/SKKCandidateTEST.cpp	Fri Dec 29 09:50:16 2006
@@ -0,0 +1,34 @@
+#include <cassert>
+#include <iostream>
+#include "Dictionary.h"
+
+int main() {
+    SKKCandidate c1;
+
+    assert(c1.IsEmpty());
+    assert(c1.Word().empty());
+    assert(c1.Annotation().empty());
+    assert(c1.Description().empty());
+
+    SKKCandidate c2("abc", "annotation");
+
+    assert(!c2.IsEmpty());
+    assert(c2.Word() == "abc");
+    assert(c2.Annotation() == "annotation");
+    assert(c2.Description() == "abc;annotation");
+    assert(!(c1 == c2));
+
+    SKKCandidate c3("abc;annotation2");
+
+    assert(!c3.IsEmpty());
+    assert(c3.Word() == "abc");
+    assert(c3.Annotation() == "annotation2");
+    assert(c3.Description() == "abc;annotation2");
+    assert(c2 == c3);
+
+    SKKCandidate c4(c3);
+
+    assert(c3 == c4);
+
+    return 0;
+}
Index: AquaSKK/tests/SKKEntryTEST.cpp
diff -u /dev/null AquaSKK/tests/SKKEntryTEST.cpp:1.1
--- /dev/null	Fri Dec 29 09:50:16 2006
+++ AquaSKK/tests/SKKEntryTEST.cpp	Fri Dec 29 09:50:16 2006
@@ -0,0 +1,108 @@
+#include <cassert>
+#include <iostream>
+#include "Dictionary.h"
+
+int main() {
+    SKKEntry e1 = SKKEntry::ParseOkuriNasi("key", "/abc/def/ghi/");
+
+    assert(e1.Key() == "key");
+    assert(e1.Candidate() == "/abc/def/ghi/");
+    assert(e1.Candidate(':') == ":abc:def:ghi:");
+    assert(e1.Join() == "/abc/def/ghi/");
+    assert(e1.Join(':') == ":abc:def:ghi:");
+    assert(e1.Description() == "key /abc/def/ghi/");
+    assert(e1.First() == SKKCandidate("abc"));
+    assert(e1.Next() == SKKCandidate("def"));
+    assert(e1.Next() == SKKCandidate("ghi"));
+    assert(e1.Count() == 3);
+    assert(e1.FirstHint().IsEmpty());
+    assert(e1.NextHint().IsEmpty());
+    assert(e1.HintCount() == 0);
+
+    e1 = SKKEntry::ParseOkuriAri("key", "/abc/def/ghi/[a/abc/def/]/[b/def/ghi/]/");
+
+    assert(e1.Key() == "key");
+    assert(e1.Candidate() == "/abc/def/ghi/[a/abc/def/]/[b/def/ghi/]/");
+    assert(e1.Candidate(':') == ":abc:def:ghi:[a/abc/def/]:[b/def/ghi/]:");
+    assert(e1.Join() == "/abc/def/ghi/[a/abc/def/]/[b/def/ghi/]/");
+    assert(e1.Join(':') == ":abc:def:ghi:[a/abc/def/]:[b/def/ghi/]:");
+    assert(e1.Description() == "key /abc/def/ghi/[a/abc/def/]/[b/def/ghi/]/");
+    assert(e1.First() == SKKCandidate("abc"));
+    assert(e1.Next() == SKKCandidate("def"));
+    assert(e1.Next() == SKKCandidate("ghi"));
+    assert(e1.Count() == 3);
+    assert(e1.FirstHint().Word() == "[a/abc/def/]");
+    assert(e1.NextHint().Word() == "[b/def/ghi/]");
+    assert(e1.HintCount() == 2);
+
+    e1 = SKKEntry::ParseOkuriNasi("key", "/abc/");
+    SKKEntry e2 = SKKEntry::ParseOkuriNasi("key", "/def/");
+
+    e1.Add(e2);
+    assert(e1.Join() == "/abc/def/");
+
+    e1.AddHint(SKKOkuriHint("a", SKKCandidate("abc")));
+
+    assert(e1.Join() == "/abc/def/[a/abc/]/");
+
+    e1 = SKKEntry::CreateOkuriNasi("key");
+    e1.Add(SKKCandidate("abc"), "a");
+    e1.Add(SKKCandidate("def"), "b");
+    assert(e1.Join() == "/abc/def/[a/abc/]/[b/def/]/");
+
+    e2 = SKKEntry::CreateOkuriNasi("key");
+    e2.Add(SKKCandidate("ABC"), "A");
+    e2.Add(SKKCandidate("DEF"), "B");
+    e2.Add(SKKCandidate("GHI"), "A");
+    e1.Add(e2);
+
+    assert(e1.Join() == "/abc/def/ABC/DEF/GHI/[a/abc/]/[b/def/]/[A/ABC/GHI/]/[B/DEF/]/");
+
+    e1.Add(SKKCandidate("xyz"));
+
+    assert(e1.Join() == "/abc/def/ABC/DEF/GHI/xyz/[a/abc/]/[b/def/]/[A/ABC/GHI/]/[B/DEF/]/");
+
+    e1.Remove(SKKCandidate("GHI"));
+
+    assert(e1.Join() == "/abc/def/ABC/DEF/xyz/[a/abc/]/[b/def/]/[A/ABC/]/[B/DEF/]/");
+
+    e1.Remove(SKKCandidate("ABC"));
+    e1.Remove(SKKCandidate("DEF"));
+
+    assert(e1.Join() == "/abc/def/xyz/[a/abc/]/[b/def/]/");
+
+    e1.Update(SKKCandidate("xyz"));
+
+    assert(e1.Join() == "/xyz/abc/def/[a/abc/]/[b/def/]/");
+
+    e1.Update(SKKCandidate("abc"), "b");
+
+    assert(e1.Join() == "/abc/xyz/def/[a/abc/]/[b/abc/def/]/");
+
+    e1.Remove(SKKCandidate("abc"));
+
+    assert(e1.Join() == "/xyz/def/[b/def/]/");
+
+    SKKEntry e3 = SKKEntry::ParseOkuriNasi("かんじ", "/漢字[3b][20][2f]/[5b]完治/");
+
+    assert(e3.Join() == "/漢字[3b][20][2f]/[5b]完治/");
+
+    SKKEntry e4 = SKKEntry::ParseOkuriAri("おおk", "/大/多/夛;「多」の異体字/");
+
+    assert(e4.Candidate() == "/大/多/夛;「多」の異体字/");
+    assert(e4.Join() == "/大/多/夛/");
+
+    SKKEntry e5 = SKKEntry::ParseOkuriNasi("suwa", "/Tomotaka SUWA <t.suw****@mac*****>/");
+
+    assert(e5.Join() == "/Tomotaka SUWA <t.suw****@mac*****>/");
+
+    SKKEntry e6 = SKKEntry::ParseOkuriNasi("key", "//abc///def///");
+
+    assert(e6.Join() == "/abc/def/");
+
+    SKKEntry e7 = SKKEntry::ParseOkuriAri("key", "///abc///def/[a///abc///def///]//");
+
+    assert(e7.Candidate() == "/abc/def/[a/abc/def/]/");
+
+    return 0;
+}
Index: AquaSKK/tests/SKKOkuriHintTEST.cpp
diff -u /dev/null AquaSKK/tests/SKKOkuriHintTEST.cpp:1.1
--- /dev/null	Fri Dec 29 09:50:16 2006
+++ AquaSKK/tests/SKKOkuriHintTEST.cpp	Fri Dec 29 09:50:16 2006
@@ -0,0 +1,52 @@
+#include <cassert>
+#include <iostream>
+#include "Dictionary.h"
+
+int main() {
+    SKKOkuriHint h1;
+
+    assert(h1.IsEmpty());
+    assert(h1.Kana().empty());
+    assert(h1.First().IsEmpty());
+    assert(h1.Next().IsEmpty());
+    assert(h1.Count() == 0);
+    assert(h1.Description().empty());
+    assert(h1.Word().empty());
+
+    h1.SetKana("a");
+    assert(h1.Kana() == "a");
+    
+    h1.Add(SKKCandidate("abc;123"));
+    h1.Add(SKKCandidate("def;456"));
+    h1.Add(SKKCandidate("ghi;789"));
+
+    assert(h1.Description() == "[a/abc;123/def;456/ghi;789/]");
+    assert(h1.Word() == "[a/abc/def/ghi/]");
+
+    h1.Update(SKKCandidate("def;!@#"));
+
+    assert(h1.Description() == "[a/def;!@#/abc;123/ghi;789/]");
+    assert(h1.Word() == "[a/def/abc/ghi/]");
+
+    h1.Remove(SKKCandidate("ghi"));
+
+    assert(h1.Word() == "[a/def/abc/]");
+
+    h1.Remove(SKKCandidate("def"));
+
+    assert(h1.Word() == "[a/abc/]");
+
+    h1.Remove(SKKCandidate("abc"));
+
+    assert(h1.Word().empty());
+
+    SKKOkuriHint h2("a/abc/def/ghi/");
+
+    assert(h2.Word() == "[a/abc/def/ghi/]");
+
+    SKKOkuriHint h3("aabc//");
+
+    assert(h3.Word().empty());
+
+    return 0;
+}


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