func BenchmarkCL32k(b *testing.B) { for _, t := range tests { reader := NewReader(t.fn) buf := new(bytes.Buffer) io.CopyN(buf, reader, 32*1024) s := buf.String() for n := 0; n < b.N; n++ { cld2_nlpt.DetectLanguage(len(s), s, "code") } } }
func TestCL(t *testing.T) { for _, c := range tests { reader := NewReader(c.fn) buf := new(bytes.Buffer) for _, size := range []int64{8192, 32768} { io.CopyN(buf, reader, size) s := buf.String() code, err := cld2_nlpt.DetectLanguage(len(s), s, "code") if err != nil { t.Error(err) } if !stringInSlice(string(code), c.lang) { t.Errorf("%s: got %s, want one of %+v", c.fn, string(code), c.lang) } } } }