func BenchmarkLD32k(b *testing.B) { for _, t := range tests { reader := NewReader(t.fn) buf := new(bytes.Buffer) io.CopyN(buf, reader, 32*1024) for n := 0; n < b.N; n++ { langdetect.DetectLanguage(buf.Bytes(), "") } } }
func TestLD(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) result := langdetect.DetectLanguage(buf.Bytes(), "") code := fmt.Sprintf("%s", result) if !stringInSlice(code, c.lang) { t.Errorf("%s: got %s, want one of %+v", c.fn, code, c.lang) } } } }