1
0
mirror of https://github.com/fumiama/jieba.git synced 2026-06-26 23:20:31 +08:00

updated all tests to use Fatal/Fatalf to fail tests ealier

This commit is contained in:
Wang Bin
2015-03-30 18:01:21 +08:00
parent c397cafe8a
commit 7cf16072e6
7 changed files with 53 additions and 53 deletions

View File

@@ -18,11 +18,11 @@ func TestViterbi(t *testing.T) {
states := []byte{'B', 'M', 'E', 'S'}
prob, path := viterbi([]rune(obs), states)
if math.Abs(prob+39.68824128493802) > 1e-10 {
t.Error(prob)
t.Fatal(prob)
}
for index, state := range []byte{'B', 'E', 'S', 'B', 'M', 'E'} {
if path[index] != state {
t.Error(path)
t.Fatal(path)
}
}
}
@@ -31,16 +31,16 @@ func TestCutHan(t *testing.T) {
obs := "我们是程序员"
result := chanToArray(cutHan(obs))
if len(result) != 3 {
t.Error(result)
t.Fatal(result)
}
if result[0] != "我们" {
t.Error(result[0])
t.Fatal(result[0])
}
if result[1] != "是" {
t.Error(result[1])
t.Fatal(result[1])
}
if result[2] != "程序员" {
t.Error(result[2])
t.Fatal(result[2])
}
}
@@ -48,24 +48,24 @@ func TestCut(t *testing.T) {
sentence := "我们是程序员"
result := chanToArray(Cut(sentence))
if len(result) != 3 {
t.Error(len(result))
t.Fatal(len(result))
}
if result[0] != "我们" {
t.Error(result[0])
t.Fatal(result[0])
}
if result[1] != "是" {
t.Error(result[1])
t.Fatal(result[1])
}
if result[2] != "程序员" {
t.Error(result[2])
t.Fatal(result[2])
}
result2 := chanToArray(Cut("I'm a programmer!"))
if len(result2) != 8 {
t.Error(result2)
t.Fatal(result2)
}
result3 := chanToArray(Cut("程序员average年龄28.6岁。"))
if len(result3) != 6 {
t.Error(result3)
t.Fatal(result3)
}
}