Skip to content

Commit

Permalink
add stroke count tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shawnps committed Feb 22, 2014
1 parent d5e89f7 commit 98694b0
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
kanjidic2.xml
*.swp
28 changes: 28 additions & 0 deletions kanjidic2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
)

var numKanji = 13108
var kanjiList []Kanji

func TestParser(t *testing.T) {
got, err := ParseKanjiDic2("kanjidic2.xml")
Expand All @@ -14,4 +15,31 @@ func TestParser(t *testing.T) {
if len(got) != numKanji {
t.Fatalf("ParseKanjiDic2 length incorrect: got %d, want %d", got, numKanji)
}
// set kanjiList for later tests
kanjiList = got
}

var strokeCountTests = []struct {
Literal string
Count int
}{
{"ー", 1},
{"二", 2},
{"三", 3},
{"中", 4},
{"店", 8},
{"感", 13},
{"機", 16},
}

func TestStrokeCount(t *testing.T) {
for _, k := range kanjiList {
for _, tt := range strokeCountTests {
if k.Literal == tt.Literal {
if got := k.StrokeCount; got != tt.Count {
t.Errorf("TestStrokeCount (%s): got %d, want %d", tt.Literal, got, tt.Count)
}
}
}
}
}

0 comments on commit 98694b0

Please sign in to comment.