;;-*- mode: nendo; syntax: scheme -*- ;;; ;;; roman-lib.nnd - ローマ字ライブラリ部のテストスイート ;;; ;;; Copyright (c) 2010 Kiyoka Nishiyama ;;; ;;; Redistribution and use in source and binary forms, with or without ;;; modification, are permitted provided that the following conditions ;;; are met: ;;; ;;; 1. Redistributions of source code must retain the above copyright ;;; notice, this list of conditions and the following disclaimer. ;;; ;;; 2. Redistributions in binary form must reproduce the above copyright ;;; notice, this list of conditions and the following disclaimer in the ;;; documentation and/or other materials provided with the distribution. ;;; ;;; 3. Neither the name of the authors nor the names of its contributors ;;; may be used to endorse or promote products derived from this ;;; software without specific prior written permission. ;;; ;;; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ;;; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ;;; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ;;; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ;;; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ;;; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED ;;; TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR ;;; PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF ;;; LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING ;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ;;; ;;; $Id: ;;; (use nendo.test) (use sekka.roman-lib) (test-start "roman-lib") ;;=================================================================== ;;------------------------------------------------------------------- (test-section "upcase and downcase conversion") (test* "downcase 1" "aabbccddeeffgg" (sekka-downcase "aAbBcCdDeEfFgG")) (test* "downcase 2" "aaa@@@@@@bbb" (sekka-downcase "AAA@@@```BBB")) (test* "downcase 3" "aaa;;;;;;bbb" (sekka-downcase "AAA+++;;;BBB")) (test* "upcase 1" "AABBCCDDEEFFGG" (sekka-upcase "aAbBcCdDeEfFgG")) (test* "upcase 2" "AAA``````BBB" (sekka-upcase "AAA@@@```BBB")) (test* "upcase 2" "AAA++++++BBB" (sekka-upcase "AAA+++;;;BBB")) ;;------------------------------------------------------------------- (test-section "kana->roman conversion hash (short)") (test* "kana->roman 1" '("fu" "hu" "hf") (hash-table-get sekka-kana->roman-hash-short-azik "ふ" #f)) (test* "kana->roman 2" '("la" "xa" "xxa") (hash-table-get sekka-kana->roman-hash-short-azik "ぁ" #f)) (test* "kana->roman 3" '("chi" "tyi" "ti" "ci") (hash-table-get sekka-kana->roman-hash-short-azik "ち" #f)) (test* "kana->roman 4" '("tt" "@" ";" "ltu" "xtu") (hash-table-get sekka-kana->roman-hash-short-azik "っ" #f)) (test* "kana->roman 5" '("-" "^" ":" "'") (hash-table-get sekka-kana->roman-hash-short-azik "ー" #f)) (test* "kana->roman 6" '("#") (hash-table-get sekka-kana->roman-hash-short-azik "#" #f)) ;;------------------------------------------------------------------- (test-section "kana->roman conversion hash (long)") (test* "kana->roman 1" '("kz" "kn") (hash-table-get sekka-kana->roman-hash-long-azik "かん" #f)) (test* "kana->roman 2" '("kt") (hash-table-get sekka-kana->roman-hash-long-azik "こと" #f)) (test* "kana->roman 3" '("ffu" "hhu" "@fu" "@hu" ";fu" ";hu") (hash-table-get sekka-kana->roman-hash-long-azik "っふ" #f)) ;;------------------------------------------------------------------- (test-section "roman->kana conversion hash (short)") (test* "roman->kana 1" '("あ") (hash-table-get sekka-roman->kana-hash-short "a" #f)) (test* "roman->kana 2" '("っぎゃ") (hash-table-get sekka-roman->kana-hash-short "ggya" #f)) (test* "roman->kana 3" '("し") (hash-table-get sekka-roman->kana-hash-short "si" #f)) (test* "roman->kana 4" '("ー") (hash-table-get sekka-roman->kana-hash-short "-" #f)) (test* "roman->kana 5" '("ー") (hash-table-get sekka-roman->kana-hash-short ":" #f)) (test* "roman->kana 6" '("っ") (hash-table-get sekka-roman->kana-hash-short "ltu" #f)) (test* "roman->kana 7" '("っ") (hash-table-get sekka-roman->kana-hash-short "@" #f)) (test* "roman->kana 8" '("っ") (hash-table-get sekka-roman->kana-hash-short ";" #f)) (test* "roman->kana 9" '("っ") (hash-table-get sekka-roman->kana-hash-short "xtu" #f)) (test* "roman->kana 10" '("ぁ") (hash-table-get sekka-roman->kana-hash-short "xa" #f)) (test* "roman->kana 11" '("ぁ") (hash-table-get sekka-roman->kana-hash-short "xxa" #f)) (test* "roman->kana 12" '("#") (hash-table-get sekka-roman->kana-hash-short "#" #f)) ;;------------------------------------------------------------------- (test-section "roman->kana conversion hash (long)") (test* "roman->kana 1" '("かん") (hash-table-get sekka-roman->kana-hash-long "kn" #f)) (test* "roman->kana 2" '("かん") (hash-table-get sekka-roman->kana-hash-long "kz" #f)) (test* "roman->kana 3" '("こと") (hash-table-get sekka-roman->kana-hash-long "kt" #f)) (test* "roman->kana 4" '("です") (hash-table-get sekka-roman->kana-hash-long "ds" #f)) (test* "roman->kana 5" '("ます") (hash-table-get sekka-roman->kana-hash-long "ms" #f)) (test* "roman->kana 6" '("なん") (hash-table-get sekka-roman->kana-hash-long "nz" #f)) (test* "roman->kana 7" '("ふぉん") (hash-table-get sekka-roman->kana-hash-long "fl" #f)) ;;------------------------------------------------------------------- (test-section "hiragana<->katanaka conversion functions") (test* "hiragana->katakana 1" "アイウエオーァィゥェォッ" (gen-hiragana->katakana "あいうえおーぁぃぅぇぉっ")) (test* "hiragana->katakana 2" "パイナップル" (gen-hiragana->katakana "ぱいなっぷる")) (test* "hiragana->katakana 3" "アメニモマケズ" (gen-hiragana->katakana "あめにもまけず")) (test* "hiragana->katakana 1" "あいうえおーぁぃぅぇぉっ" (gen-katakana->hiragana "アイウエオーァィゥェォッ")) (test* "hiragana->katakana 2" "ありがとうございます" (gen-katakana->hiragana "アリガトウゴザイマス")) (test* "hiragana->katakana 3" "いろはにほへとちりぬるを" (gen-katakana->hiragana "イロハニホヘトチリヌルヲ")) (test* "is katakana 1" #t (is-katakana "アメニモマケズ")) (test* "is katakana 2" #f (is-katakana "englishア")) (test* "is katakana 3" #f (is-katakana "アenglish")) (test* "is katakana 4" #f (is-katakana "engアlish")) (test* "is katakana 5" #f (is-katakana "あア")) (test* "is katakana 6" #f (is-katakana "アメニEモマケズ")) (test* "is katakana 7" #t (is-katakana "コーヒー")) (test* "is hiragana 1" #t (is-hiragana "ひらがなのぶんしょう")) (test* "is hiragana 2" #f (is-hiragana "ひらがなノぶんしょう")) (test* "is hiragana 3" #f (is-hiragana "Eひらがなのぶんしょう")) (test* "is hiragana 4" #f (is-hiragana "ひらがなEのぶんしょう")) (test* "is hiragana 5" #f (is-hiragana "ひらがなのぶんしょうE")) (test* "is hiragana 6" #f (is-hiragana "あア")) (test* "is hiragana 7" #t (is-hiragana "こーひー")) (test* "is hiragana-and-okuri 1" #t (is-hiragana-and-okuri "あr")) (test* "is hiragana-and-okuri 2" #f (is-hiragana-and-okuri "あ")) (test* "is hiragana-and-okuri 3" #t (is-hiragana-and-okuri "おこなu")) (test* "is hiragana-and-okuri 4" #f (is-hiragana-and-okuri "おこなU")) (test* "is hiragana-and-okuri 5" #f (is-hiragana-and-okuri "a")) (test* "is hiragana-and-okuri 6" #f (is-hiragana-and-okuri "au")) (test* "is hiragana-and-okuri 7" #f (is-hiragana-and-okuri "1")) (test* "is hiragana-and-okuri 8" #f (is-hiragana-and-okuri "123")) ;;------------------------------------------------------------------- (test-section "drop okurigana functions") (test* "drop okri 1" "行" (drop-okuri "行う")) (test* "drop okri 2" "行" (drop-okuri "行なう")) (test* "drop okri 3" "見" (drop-okuri "見る")) (test* "drop okri 4" "変化" (drop-okuri "変化する")) (test* "drop okri 5" "見付" (drop-okuri "見付ける")) ;;------------------------------------------------------------------- (test-section "kana->roman conversion functions") (let1 hira-list (hash-table-keys sekka-kana->roman-hash-long-azik) (test* "kana->roman table length" 524 (length hira-list)) (test* "kana->roman key duplicate check" 524 (length (uniq (sort hira-list))))) (test* "hiragana -> roman-pattern0" '( (("ka") ("nn" "n" "q")) (("kz" "kn"))) (gen-hiragana->roman-pattens "かん")) (test* "hiragana -> roman-pattern1" '( (("ka") ("nn" "n" "q") ("ji" "zi")) (("kz" "kn") ("ji" "zi"))) (gen-hiragana->roman-pattens "かんじ")) (test* "hiragana -> roman-pattern2" '( (("he") ("nn" "n" "q") ("ka") ("nn" "n" "q")) (("hd") ("kz" "kn"))) (gen-hiragana->roman-pattens "へんかん")) (test* "hiragana -> roman-pattern3" '( (("ka") ("nn" "n" "q") ("ji" "zi") ("he") ("nn" "n" "q") ("ka") ("nn" "n" "q")) (("kz" "kn") ("ji" "zi") ("hd") ("kz" "kn"))) (gen-hiragana->roman-pattens "かんじへんかん")) (test* "hiragana -> roman-pattern4" '( (("shi" "si") ("ze" "zf") ("nn" "n" "q") ("ge") ("nn" "n" "q") ("go") ("sho" "syo") ("ri")) (("shi" "si" "xi") ("zd") ("gd") ("go") ("sho" "syo" "xo") ("ri"))) (gen-hiragana->roman-pattens "しぜんげんごしょり")) (test* "hiragana -> roman-pattern5" '((("ka") ("kko" "@ko" ";ko"))) (gen-hiragana->roman-pattens "かっこ")) (test* "patterns -> roman-list1" '("kanji" "kannji" "kannzi" "kanzi" "kaqji" "kaqzi" "knji" "knzi" "kzji" "kzzi") (patterns->roman-list '( (("ka") ("nn" "n" "q") ("ji" "zi")) (("kz" "kn") ("ji" "zi"))))) (test* "patterns -> roman-list2" '("shizdgdgoshori" "shizdgdgosyori" "shizdgdgoxori" "shizengengoshori" "shizengengosyori" "shizengengoxori" "shizengenngoshori" "shizengenngosyori" "shizengenngoxori" "shizengeqgoshori" "shizengeqgosyori" "shizengeqgoxori" "shizenngengoshori" "shizenngengosyori" "shizenngengoxori" "shizenngenngoshori" "shizenngenngosyori" "shizenngenngoxori" "shizenngeqgoshori" "shizenngeqgosyori" "shizenngeqgoxori" "shizeqgengoshori" "shizeqgengosyori" "shizeqgengoxori" "shizeqgenngoshori" "shizeqgenngosyori" "shizeqgenngoxori" "shizeqgeqgoshori" "shizeqgeqgosyori" "shizeqgeqgoxori" "sizdgdgoshori" "sizdgdgosyori" "sizdgdgoxori" "sizengengoshori" "sizengengosyori" "sizengengoxori" "sizengenngoshori" "sizengenngosyori" "sizengenngoxori" "sizengeqgoshori" "sizengeqgosyori" "sizengeqgoxori" "sizenngengoshori" "sizenngengosyori" "sizenngengoxori" "sizenngenngoshori" "sizenngenngosyori" "sizenngenngoxori" "sizenngeqgoshori" "sizenngeqgosyori" "sizenngeqgoxori" "sizeqgengoshori" "sizeqgengosyori" "sizeqgengoxori" "sizeqgenngoshori" "sizeqgenngosyori" "sizeqgenngoxori" "sizeqgeqgoshori" "sizeqgeqgosyori" "sizeqgeqgoxori") (patterns->roman-list '( (("shi" "si") ("ze") ("nn" "n" "q") ("ge") ("nn" "n" "q") ("go") ("sho" "syo" "xo") ("ri")) (("shi" "si") ("zd") ("gd") ("go") ("sho" "syo" "xo") ("ri"))))) (test* "hiragana -> roman-list1" '("kanji" "kannji" "kannzi" "kanzi" "kaqji" "kaqzi" "knji" "knzi" "kzji" "kzzi") (gen-hiragana->roman-list "かんじ")) (test* "hiragana -> roman-list2" '("nishiyama" "nisiyama" "nixiyama") (gen-hiragana->roman-list "にしやま")) (test* "hiragana -> roman-list3" '("toukgou" "toukgowhu" "toukyou" "toukyowhu" "towhukgou" "towhukgowhu" "towhukyou" "towhukyowhu" "tpkgp" "tpkyp") (gen-hiragana->roman-list "とうきょう")) (test* "hiragana -> roman-list4" '("ko'hi'" "ko'hi-" "ko'hi:" "ko'hi^" "ko-hi'" "ko-hi-" "ko-hi:" "ko-hi^" "ko:hi'" "ko:hi-" "ko:hi:" "ko:hi^" "ko^hi'" "ko^hi-" "ko^hi:" "ko^hi^") (gen-hiragana->roman-list "こーひー")) (test* "hiragana -> roman-list5" '("tsumikf" "tsumiki" "tumikf" "tumiki") (gen-hiragana->roman-list "つみき")) (test* "hiragana -> roman-list6" '("gyoume" "gyowhume" "gypme") (gen-hiragana->roman-list "ぎょうめ")) (test* "hiragana -> roman-list7" '("#gyoume" "#gyowhume" "#gypme") (gen-hiragana->roman-list "#ぎょうめ")) ;;------------------------------------------------------------------- (test-section "roman->kana conversion functions") (test* "roman -> hiragana 1" '("つみき") (gen-roman->hiragana "tsumiki" :normal)) (test* "roman -> hiragana 2" '("こーひー") (gen-roman->hiragana "ko-hi-" :normal)) (test* "roman -> hiragana 3" '("かんじ" "かぬんい") (gen-roman->hiragana "kanji" :normal)) (test* "roman -> hiragana 4" '("かぬんい" "かんじ") (gen-roman->hiragana "kanji" :azik)) (test* "roman -> hiragana 5" '("かんじ") (gen-roman->hiragana "kannji" :normal)) (test* "roman -> hiragana 6" '("ちゃんじ" "ちゃなんい") (gen-roman->hiragana "canzi" :normal)) (test* "roman -> hiragana 7" '("ちゃなんい" "ちゃんじ") (gen-roman->hiragana "canzi" :azik)) (test* "roman -> hiragana 8" '("とうきょうとっきょきょかきょく") (gen-roman->hiragana "toukyoutokkyokyokakyoku" :normal)) (test* "roman -> hiragana 9" '("はっぴょうってきょうかぁ") (gen-roman->hiragana "happyouttekyoukala" :normal)) (test* "roman -> hiragana 10" '("はっぴょうってきょうかぁ") (gen-roman->hiragana "ha@pyou@tekyoukala" :normal)) (test* "roman -> hiragana 11" '("かんじ") (gen-roman->hiragana "knji" :normal)) (test* "roman -> hiragana 12" '("かっこ") (gen-roman->hiragana "ka@ko" :normal)) (test* "roman -> hiragana 13" '("こーひー") (gen-roman->hiragana "ko:hi:" :normal)) (test* "roman -> hiragana 14" '() (gen-roman->hiragana "b" :normal)) (test* "roman -> hiragana 15" '("んんんん") (gen-roman->hiragana "nnqnnq" :normal)) (test* "roman -> hiragana 16" '("んんんん" "ないない") (gen-roman->hiragana "nqnq" :normal)) (test* "roman -> hiragana 17" '("ないない" "んんんん") (gen-roman->hiragana "nqnq" :azik)) (test* "roman -> hiragana 18" '("そうです") (gen-roman->hiragana "spds" :normal)) (test* "roman -> hiragana 19" '("そうです") (gen-roman->hiragana "spds" :azik)) (test* "roman -> hiragana 20" '("もうしょ") (gen-roman->hiragana "mpxo" :normal)) (test* "roman -> hiragana 21" '("もうしょ") (gen-roman->hiragana "mpxo" :azik)) (test* "roman -> hiragana 22" '("ものこと") (gen-roman->hiragana "mnkt" :normal)) (test* "roman -> hiragana 23" '("ものこと") (gen-roman->hiragana "mnkt" :azik)) (test* "roman -> hiragana 24" '("しぜんげんごしょり" "しぜにぇにょしょり") (gen-roman->hiragana "shizengengosyori" :normal)) (test* "roman -> hiragana 25" '("しぜにぇにょしょり" "しぜんげんごしょり") (gen-roman->hiragana "shizengengosyori" :azik)) (test* "roman -> hiragana 26" '("しぜんげんごしょり") (gen-roman->hiragana "shizenngenngosyori" :normal)) (test* "roman -> hiragana 27" '("かっこ") (gen-roman->hiragana "ka@ko" :normal)) (test* "roman -> hiragana 28" '("かった") (gen-roman->hiragana "ka@ta" :normal)) (test* "roman -> hiragana 29" '("かっこ") (gen-roman->hiragana "ka;ko" :normal)) (test* "roman -> hiragana 30" '("かった") (gen-roman->hiragana "ka;ta" :normal)) (test* "roman -> hiragana 31" '("ぁぃぅぇぉ" "しゃししゅしぇしょ") (gen-roman->hiragana "xaxixuxexo" :normal)) (test* "roman -> hiragana 32" '("ゃゅょ") (gen-roman->hiragana "xyaxyuxyo" :normal)) (test* "roman -> hiragana 33" '("ゎっ") (gen-roman->hiragana "xwaxtu" :normal)) ;;=================================================================== (test-end)