mox/junk/parse_test.go

34 lines
684 B
Go
Raw Normal View History

2023-01-30 16:27:06 +03:00
package junk
import (
"os"
"testing"
)
func FuzzParseMessage(f *testing.F) {
f.Add("")
add := func(p string) {
buf, err := os.ReadFile(p)
if err != nil {
f.Fatalf("reading file %q: %v", p, err)
}
f.Add(string(buf))
}
add("../testdata/junk/parse.eml")
add("../testdata/junk/parse2.eml")
add("../testdata/junk/parse3.eml")
dbPath := "../testdata/junk/parse.db"
bloomPath := "../testdata/junk/parse.bloom"
os.Remove(dbPath)
os.Remove(bloomPath)
params := Params{Twograms: true}
jf, err := NewFilter(ctxbg, xlog, params, dbPath, bloomPath)
2023-01-30 16:27:06 +03:00
if err != nil {
f.Fatalf("new filter: %v", err)
}
f.Fuzz(func(t *testing.T, s string) {
jf.tokenizeMail(s)
})
}