go/tagengine/ngram_test.go

32 lines
453 B
Go
Raw Normal View History

2024-11-11 05:36:55 +00:00
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)
}
}
}