mirror of
https://github.com/mjl-/mox.git
synced 2024-12-27 08:53:48 +03:00
33 lines
684 B
Go
33 lines
684 B
Go
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)
|
|
if err != nil {
|
|
f.Fatalf("new filter: %v", err)
|
|
}
|
|
f.Fuzz(func(t *testing.T, s string) {
|
|
jf.tokenizeMail(s)
|
|
})
|
|
}
|