Tomotaka SUWA
t-suw****@users*****
2007年 2月 3日 (土) 16:53:31 JST
Index: AquaSKK/tests/Makefile diff -u AquaSKK/tests/Makefile:1.1.2.1 AquaSKK/tests/Makefile:1.1.2.2 --- AquaSKK/tests/Makefile:1.1.2.1 Sat Dec 30 15:52:55 2006 +++ AquaSKK/tests/Makefile Sat Feb 3 16:53:31 2007 @@ -1,10 +1,11 @@ -# $Id: Makefile,v 1.1.2.1 2006/12/30 06:52:55 t-suwa Exp $ +# $Id: Makefile,v 1.1.2.2 2007/02/03 07:53:31 t-suwa Exp $ # # Makefile for Unit Test # -TARGET = SKKCandidateTEST SKKOkuriHintTEST SKKEntryTEST +TARGET = SKKCandidateTEST SKKOkuriHintTEST SKKEntryTEST SKKInputKeymapTEST SKKConverterTEST \ + utf8iteratorTEST CXXFLAGS= -I.. -g all: $(TARGET) @@ -28,4 +29,19 @@ SKKEntryTEST: SKKEntryTEST.o $(CXX) -o $@ $< +SKKInputKeymapTEST: SKKInputKeymapTEST.o + $(CXX) -o $@ $< + +SKKConverterTEST: SKKConverterTEST.o + $(CXX) -o $@ $< + +utf8iteratorTEST: utf8iteratorTEST.o + $(CXX) -o $@ $< + SKKCandidateTEST.o SKKOkuriHintTEST.o SKKEntryTEST.o: ../Dictionary.h + +SKKInputKeymapTEST.o: ../SKKInputKeymap.h ../SKKInputKeymap.cpp + +SKKConverterTEST.o: ../SKKConverter.h ../SKKConverter.cpp + +utf8iteratorTEST.o: ../utf8iterator.h \ No newline at end of file Index: AquaSKK/tests/SKKConverterTEST.cpp diff -u /dev/null AquaSKK/tests/SKKConverterTEST.cpp:1.1.2.1 --- /dev/null Sat Feb 3 16:53:31 2007 +++ AquaSKK/tests/SKKConverterTEST.cpp Sat Feb 3 16:53:31 2007 @@ -0,0 +1,69 @@ +#include "SKKConverter.cpp" +#include "jconv.cpp" + +int main() { + SKKConverter& conv = SKKConverter::theInstance(); + + conv.Initialize("kana-rule-list"); + + std::string in; + std::string out; + std::string next; + + out = conv.Execute(SKK::Hirakana, "a", next); + assert(next == "" && out == "ã"); + out = conv.Execute(SKK::Katakana, "a", next); + assert(next == "" && out == "ã¢"); + out = conv.Execute(SKK::Jisx0201Kana, "a", next); + assert(next == "" && out == "ï½±"); + + out = conv.Execute(SKK::Hirakana, "gg", next); + assert(next == "g" && out == "ã£"); + + out = conv.Execute(SKK::Hirakana, ",", next); + assert(next == "" && out == "ã"); + + out = conv.Execute(SKK::Hirakana, "#", next); + assert(next == "" && out == "ï¼"); + + out = conv.Execute(SKK::Hirakana, " ", next); + assert(next == "" && out == "ã"); + + out = conv.Execute(SKK::Hirakana, "z,", next); + assert(next == "" && out == "â¥"); + + out = conv.Execute(SKK::Hirakana, "co", next); + assert(next == "" && out == "ã"); + + out = conv.Execute(SKK::Hirakana, "'", next); + assert(next == "" && out == "'"); + + out = conv.Execute(SKK::Hirakana, "k1", next); + assert(next == "" && out == "1"); + + out = conv.Execute(SKK::Hirakana, "kgya", next); + assert(next == "" && out == "ãã"); + + out = conv.Execute(SKK::Hirakana, "k1234gya", next); + assert(next == "" && out == "1234ãã"); + + out = conv.Execute(SKK::Hirakana, "gyagyugyo", next); + assert(next == "" && out == "ãããã ãã"); + + out = conv.Execute(SKK::Hirakana, "chho", next); + assert(next == "" && out == "ã»"); + + out = conv.Execute(SKK::Hirakana, "c", next); + assert(next == "c" && out == ""); + + out = conv.Execute(SKK::Hirakana, "pmp", next); + assert(next == "p" && out == ""); + + out = conv.Execute(SKK::Hirakana, "pmpo", next); + assert(next == "" && out == "ã½"); + + out = conv.Execute(SKK::Hirakana, "kanji", next); + assert(next == "" && out == "ããã"); + + return 0; +} Index: AquaSKK/tests/SKKInputKeymapTEST.cpp diff -u /dev/null AquaSKK/tests/SKKInputKeymapTEST.cpp:1.1.2.1 --- /dev/null Sat Feb 3 16:53:31 2007 +++ AquaSKK/tests/SKKInputKeymapTEST.cpp Sat Feb 3 16:53:31 2007 @@ -0,0 +1,34 @@ +#include <iostream> +#include "SKKInputKeymap.cpp" + +int main() { + SKKInputKeymap keymap; + SKKEventParam param; + + keymap.Initialize("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)); + + return 0; +} Index: AquaSKK/tests/kana-rule-list diff -u /dev/null AquaSKK/tests/kana-rule-list:1.1.2.1 --- /dev/null Sat Feb 3 16:53:31 2007 +++ AquaSKK/tests/kana-rule-list Sat Feb 3 16:53:31 2007 @@ -0,0 +1,289 @@ +# $Id: kana-rule-list,v 1.1.2.1 2007/02/03 07:53:31 t-suwa Exp $ + +# このファイルは改行コードがLF、文字エンコーディングがEUC-JPでなければなりません。 +# 五つ目の項目は次状態です。無ければ項目自体を省略します。 +# エントリの順序には気を付けて下さい。例えば「ba」というエントリに出会うと、 +# AquaSKKはまず「b」という枝を探しますが、ここではまだ存在しないので +# 「b」という空の枝を作成します。この後に「b」というエントリが現れると +# そのエントリ「b」は既に定義されているのでどうなるか分かりません。 + +# 最初の項目の,は半角カンマに置換されます。 + +invalid1 +invalid2,data +invalid3,data,test +invalid4,data,test, +invalid5,,test,fail +invalid6,,,fail +invalid7,,, +,,,,invalid8 + +#,,、,、,, +&space;, , ,&space; +♯,#,#,♯ + +a,あ,ア,ア + +bb,っ,ッ,ッ,b +ba,ば,バ,バ +bi,び,ビ,ビ +bu,ぶ,ブ,ブ +be,べ,ベ,ベ +bo,ぼ,ボ,ボ +bya,びゃ,ビャ,ビャ +byi,びぃ,ビィ,ビィ +byu,びゅ,ビュ,ビュ +bye,びぇ,ビェ,ビェ +byo,びょ,ビョ,ビョ + +cc,っ,ッ,ッ,c +cha,ちゃ,チャ,チャ +chi,ち,チ,チ +chu,ちゅ,チュ,チュ +che,ちぇ,チェ,チェ +cho,ちょ,チョ,チョ +cya,ちゃ,チャ,チャ +cyi,ちぃ,チィ,チィ +cyu,ちゅ,チュ,チュ +cye,ちぇ,チェ,チェ +cyo,ちょ,チョ,チョ + +dd,っ,ッ,ッ,d +da,だ,ダ,ダ +di,ぢ,ヂ,ヂ +du,づ,ヅ,ヅ +de,で,デ,デ +do,ど,ド,ド +dha,でゃ,デャ,デャ +dhi,でぃ,ディ,ディ +dhu,でゅ,デュ,デュ +dhe,でぇ,デェ,デェ +dho,でょ,デョ,デョ +dya,ぢゃ,ヂャ,ヂャ +dyi,ぢぃ,ヂィ,ヂィ +dyu,ぢゅ,ヂュ,ヂュ +dye,ぢぇ,ヂェ,ヂェ +dyo,ぢょ,ヂョ,ヂョ + +e,え,エ,エ + +ff,っ,ッ,ッ,f +fa,ふぁ,ファ,ファ +fi,ふぃ,フィ,フィ +fu,ふ,フ,フ +fe,ふぇ,フェ,フェ +fo,ふぉ,フォ,フォ +fya,ふゃ,フャ,フャ +fyi,ふぃ,フィ,フィ +fyu,ふゅ,フュ,フュ +fye,ふぇ,フェ,フェ +fyo,ふょ,フョ,フョ + +gg,っ,ッ,ッ,g +ga,が,ガ,ガ +gi,ぎ,ギ,ギ +gu,ぐ,グ,グ +ge,げ,ゲ,ゲ +go,ご,ゴ,ゴ +gya,ぎゃ,ギャ,ギャ +gyi,ぎぃ,ギィ,ギィ +gyu,ぎゅ,ギュ,ギュ +gye,ぎぇ,ギェ,ギェ +gyo,ぎょ,ギョ,ギョ + +hh,っ,ッ,ッ,h +ha,は,ハ,ハ +hi,ひ,ヒ,ヒ +hu,ふ,フ,フ +he,へ,ヘ,ヘ +ho,ほ,ホ,ホ +hya,ひゃ,ヒャ,ヒャ +hyi,ひぃ,ヒィ,ヒィ +hyu,ひゅ,ヒュ,ヒュ +hye,ひぇ,ヒェ,ヒェ +hyo,ひょ,ヒョ,ヒョ + +i,い,イ,イ + +jj,っ,ッ,ッ,j +ja,じゃ,ジャ,ジャ +ji,じ,ジ,ジ +ju,じゅ,ジュ,ジュ +je,じぇ,ジェ,ジェ +jo,じょ,ジョ,ジョ +jya,じゃ,ジャ,ジャ +jyi,じぃ,ジィ,ジィ +jyu,じゅ,ジュ,ジュ +jye,じぇ,ジェ,ジェ +jyo,じょ,ジョ,ジョ + +kk,っ,ッ,ッ,k +ka,か,カ,カ +ki,き,キ,キ +ku,く,ク,ク +ke,け,ケ,ケ +ko,こ,コ,コ +kya,きゃ,キャ,キャ +kyi,きぃ,キィ,キィ +kyu,きゅ,キュ,キュ +kye,きぇ,キェ,キェ +kyo,きょ,キョ,キョ + +mm,っ,ッ,ッ,m +ma,ま,マ,マ +mi,み,ミ,ミ +mu,む,ム,ム +me,め,メ,メ +mo,も,モ,モ +mya,みゃ,ミャ,ミャ +myi,みぃ,ミィ,ミィ +myu,みゅ,ミュ,ミュ +mye,みぇ,ミェ,ミェ +myo,みょ,ミョ,ミョ + +n,ん,ン,ン +n',ん,ン,ン +nn,ん,ン,ン +na,な,ナ,ナ +ni,に,ニ,ニ +nu,ぬ,ヌ,ヌ +ne,ね,ネ,ネ +no,の,ノ,ノ +nya,にゃ,ニャ,ニャ +nyi,にぃ,ニィ,ニィ +nyu,にゅ,ニュ,ニュ +nye,にぇ,ニェ,ニェ +nyo,にょ,ニョ,ニョ + +o,お,オ,オ + +pp,っ,ッ,ッ,p +pa,ぱ,パ,パ +pi,ぴ,ピ,ピ +pu,ぷ,プ,プ +pe,ぺ,ペ,ペ +po,ぽ,ポ,ポ +pya,ぴゃ,ピャ,ピャ +pyi,ぴぃ,ピィ,ピィ +pyu,ぴゅ,ピュ,ピュ +pye,ぴぇ,ピェ,ピェ +pyo,ぴょ,ピョ,ピョ + +rr,っ,ッ,ッ,r +ra,ら,ラ,ラ +ri,り,リ,リ +ru,る,ル,ル +re,れ,レ,レ +ro,ろ,ロ,ロ +rya,りゃ,リャ,リャ +ryi,りぃ,リィ,リィ +ryu,りゅ,リュ,リュ +rye,りぇ,リェ,リェ +ryo,りょ,リョ,リョ + +ss,っ,ッ,ッ,s +sa,さ,サ,サ +si,し,シ,シ +su,す,ス,ス +se,せ,セ,セ +so,そ,ソ,ソ +sha,しゃ,シャ,シャ +shi,し,シ,シ +shu,しゅ,シュ,シュ +she,しぇ,シェ,シェ +sho,しょ,ショ,ショ +sya,しゃ,シャ,シャ +syi,しぃ,シィ,シィ +syu,しゅ,シュ,シュ +sye,しぇ,シェ,シェ +syo,しょ,ショ,ショ + +tt,っ,ッ,ッ,t +ta,た,タ,タ +ti,ち,チ,チ +tu,つ,ツ,ツ +te,て,テ,テ +to,と,ト,ト +tha,てぁ,テァ,テァ +thi,てぃ,ティ,ティ +thu,てゅ,テュ,テュ +the,てぇ,テェ,テェ +tho,てょ,テョ,テョ +tsu,つ,ツ,ツ +tya,ちゃ,チャ,チャ +tyi,ちぃ,チィ,チィ +tyu,ちゅ,チュ,チュ +tye,ちぇ,チェ,チェ +tyo,ちょ,チョ,チョ + +u,う,ウ,ウ + +vv,っ,ッ,ッ,v +va,う゛ぁ,ヴァ,ヴァ +vi,う゛ぃ,ヴィ,ヴィ +vu,う゛,ヴ,ヴ +ve,う゛ぇ,ヴェ,ヴェ +vo,う゛ぉ,ヴォ,ヴォ + +ww,っ,ッ,ッ,w +wa,わ,ワ,ワ +wi,うぃ,ウィ,ウィ +wu,う,ウ,ウ +we,うぇ,ウェ,ウェ +wo,を,ヲ,ヲ + +xx,っ,ッ,ッ,x +xa,ぁ,ァ,ァ +xi,ぃ,ィ,ィ +xu,ぅ,ゥ,ゥ +xe,ぇ,ェ,ェ +xo,ぉ,ォ,ォ +xka,ヵ,ヵ,カ +xke,ヶ,ヶ,ケ +xtsu,っ,ッ,ッ +xtu,っ,ッ,ッ +xu,ぅ,ゥ,ゥ +xwa,ゎ,ヮ,ワ +xwe,ゑ,ヱ,エ +xwi,ゐ,ヰ,イ +xya,ゃ,ャ,ャ +xyo,ょ,ョ,ョ +xyu,ゅ,ュ,ュ + +yy,っ,ッ,ッ,y +ya,や,ヤ,ヤ +yi,い,イ,イ +yu,ゆ,ユ,ユ +ye,いぇ,イェ,イェ +yo,よ,ヨ,ヨ + +zz,っ,ッ,ッ,z +za,ざ,ザ,ザ +zi,じ,ジ,ジ +zu,ず,ズ,ズ +ze,ぜ,ゼ,ゼ +zo,ぞ,ゾ,ゾ +zya,じゃ,ジャ,ジャ +zyi,じぃ,ジィ,ジィ +zyu,じゅ,ジュ,ジュ +zye,じぇ,ジェ,ジェ +zyo,じょ,ジョ,ジョ +z,,‥,‥,‥ +z-,〜,〜,〜 +z.,…,…,… +z/,・,・,・ +z[,『,『,『 +z],』,』,』 +zh,←,←,← +zj,↓,↓,↓ +zk,↑,↑,↑ +zl,→,→,→ + +-,ー,ー,ー +:,:,:,: +;,;,;,; +[,「,「,「 +],」,」,」 + +.,。,。,。 +,,、,、,、 Index: AquaSKK/tests/keymap.conf diff -u /dev/null AquaSKK/tests/keymap.conf:1.1.2.1 --- /dev/null Sat Feb 3 16:53:31 2007 +++ AquaSKK/tests/keymap.conf Sat Feb 3 16:53:31 2007 @@ -0,0 +1,42 @@ +### +### keymap.conf +### + +# ====================================================================== +# event section +# ====================================================================== + +SKK_JMODE ctrl::j +SKK_ENTER group::ascii::0x03,0x0a,0x0d||ctrl::m +SKK_TAB ascii::0x09||ctrl::i +SKK_BACKSPACE ascii::0x08 +SKK_BACKSPACE ctrl::h +SKK_CANCEL ctrl::g +SKK_PASTE ctrl::y +SKK_LEFT ascii::0x1c||ctrl::b +SKK_RIGHT ascii::0x1d||ctrl::f +SKK_UP ascii::0x1e||ctrl::p +SKK_DOWN ascii::0x1f||ctrl::n + +# ====================================================================== +# attribute section(for SKK_CHAR) +# ====================================================================== + +ToggleKana q +ToggleJisx0201Kana ctrl::q +SwitchToAscii l +SwitchToJisx0208Latin L + +EnterAbbrev / +EnterJapanese Q +#EnterJapanese keycode::0x66 # EISU +#EnterJapanese keycode::0x68 # KANA +NextCompletion . +PrevCompletion , +NextCandidate ascii::0x20 +PrevCandidate x +RemoveTrigger X + +UpperCases group::A-K,M-P,R-W,Z + +Direct group::keycode::0x41,0x43,0x45,0x4b,0x4e,0x51-0x59,0x5b,0x5c,0x5f Index: AquaSKK/tests/utf8iteratorTEST.cpp diff -u /dev/null AquaSKK/tests/utf8iteratorTEST.cpp:1.1.2.1 --- /dev/null Sat Feb 3 16:53:31 2007 +++ AquaSKK/tests/utf8iteratorTEST.cpp Sat Feb 3 16:53:31 2007 @@ -0,0 +1,66 @@ +#include <cassert> +#include <iostream> +#include "utf8iterator.h" + +int main() { + std::string utf1("abcABCãããã¢ã¤ã¦ï½±ï½²ï½³æ¼¢åαβγ"); + utf8iterator iter(utf1); + + assert(*iter.first() == "a"); + assert(iter.charsize() == 1); + assert(*iter.next() == "b"); + assert(*iter.next() == "c"); + assert(*iter.next() == "A"); + assert(iter.charsize() == 3); + assert(*iter.next() == "ï¼¢"); + assert(*iter.next() == "ï¼£"); + assert(*iter.next() == "ã"); + assert(iter.charsize() == 3); + assert(*iter.next() == "ã"); + assert(*iter.next() == "ã"); + assert(*iter.next() == "ã¢"); + assert(iter.charsize() == 3); + assert(*iter.next() == "ã¤"); + assert(*iter.next() == "ã¦"); + assert(*iter.next() == "ï½±"); + assert(iter.charsize() == 3); + assert(*iter.next() == "ï½²"); + assert(*iter.next() == "ï½³"); + assert(*iter.next() == "æ¼¢"); + assert(iter.charsize() == 3); + assert(*iter.next() == "å"); + assert(*iter.next() == "留"); + assert(iter.charsize() == 2); + assert(*iter.next() == "硫"); + assert(*iter.next() == "粒"); + assert(*iter.next() == ""); + assert(*iter.next() == ""); + assert(iter.eof()); + + assert(*iter.last() == "粒"); + assert(*iter.prev() == "硫"); + assert(*iter.prev() == "留"); + assert(utf1.substr(iter) == "留硫粒"); + assert(*iter.prev() == "å"); + assert(*iter.prev() == "æ¼¢"); + assert(*iter.prev() == "ï½³"); + assert(*iter.prev() == "ï½²"); + assert(*iter.prev() == "ï½±"); + assert(*iter.prev() == "ã¦"); + assert(*iter.prev() == "ã¤"); + assert(*iter.prev() == "ã¢"); + assert(*iter.prev() == "ã"); + assert(*iter.prev() == "ã"); + assert(*iter.prev() == "ã"); + assert(*iter.prev() == "ï¼£"); + assert(*iter.prev() == "ï¼¢"); + assert(*iter.prev() == "A"); + assert(*iter.prev() == "c"); + assert(*iter.prev() == "b"); + assert(*iter.prev() == "a"); + assert(*iter.prev() == ""); + assert(*iter.prev() == ""); + assert(iter.eof()); + + return 0; +}