#!/bin/sh

. ${srcdir=.}/t.frame

INP="$TMPDIR"/test.inp
REF="$TMPDIR/test.ref"
OUT="$TMPDIR"/test.out
CORRECT="$SYSTEST/outputs/multiple.wordlists.ref"

cat <<EOF > "$INP"
From somebody@bogofilter.org
To:  somebody-else@bogofilter.org

This is a test
EOF

cat <<EOF > "$REF"
::: 1 :::
head:From
head:somebody
head:bogofilter.org
to:somebody-else
to:bogofilter.org
This
is
test
::: 2 :::
head:From
head:somebody
head:From*somebody
head:bogofilter.org
head:somebody*bogofilter.org
to:somebody-else
to:bogofilter.org
to:somebody-else*bogofilter.org
This
is
This*is
test
is*test
::: 3 :::
head:From
head:somebody
head:From*somebody
head:bogofilter.org
head:somebody*bogofilter.org
head:From*somebody*bogofilter.org
to:somebody-else
to:bogofilter.org
to:somebody-else*bogofilter.org
This
is
This*is
test
is*test
This*is*test
::: 4 :::
head:From
head:somebody
head:From*somebody
head:bogofilter.org
head:somebody*bogofilter.org
head:From*somebody*bogofilter.org
to:somebody-else
to:bogofilter.org
to:somebody-else*bogofilter.org
This
is
This*is
test
is*test
This*is*test
::: 5 :::
head:From
head:somebody
head:From*somebody
head:bogofilter.org
head:somebody*bogofilter.org
head:From*somebody*bogofilter.org
to:somebody-else
to:bogofilter.org
to:somebody-else*bogofilter.org
This
is
This*is
test
is*test
This*is*test
EOF

for COUNT in 1 2 3 4 5 ; do
    echo "::: $COUNT :::" >> $OUT
    $BOGOLEXER -C -p --min-token-len 2 --multi-token-count $COUNT < "$INP" >> "$OUT"
done

if  [ $verbose -eq 0 ]; then
    diff "$REF" "$OUT"
    cmp  "$REF" "$OUT"
else
    diff $DIFF_BRIEF "$REF" "$OUT"
fi
