wip
This commit is contained in:
31
tagengine/ngram_test.go
Normal file
31
tagengine/ngram_test.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package tagengine
|
||||
|
||||
import (
|
||||
"log"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestNGramLength(t *testing.T) {
|
||||
type Case struct {
|
||||
Input string
|
||||
Length int
|
||||
}
|
||||
|
||||
cases := []Case{
|
||||
{"a b c", 3},
|
||||
{" xyz\nlkj dflaj a", 4},
|
||||
{"a", 1},
|
||||
{" a", 1},
|
||||
{"a", 1},
|
||||
{" a\n", 1},
|
||||
{" a ", 1},
|
||||
{"\tx\ny\nz q ", 4},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
length := ngramLength(tc.Input)
|
||||
if length != tc.Length {
|
||||
log.Fatalf("%s: %d != %d", tc.Input, length, tc.Length)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user