#!/bin/sh

# Test short headers and short bodies.
# One-character long headers used to sometimes be missed;  see commit
# 41a82a7ecba04be5b27b3ffc813e2f34d2786a38.

set -e

if test -z "${MH_OBJ_DIR}"; then
    srcdir=`dirname "$0"`/../..
    MH_OBJ_DIR=`cd "$srcdir" && pwd`; export MH_OBJ_DIR
fi

. "$MH_OBJ_DIR/test/common.sh"

setup_test

mail="$MH_TEST_DIR/$$.mail"
expected="$MH_TEST_DIR/$$.expected"
actual="$MH_TEST_DIR/$$.actual"
format="$MH_TEST_DIR/$$.format"

for a in a: a:1 aa: aa:1; do
    for b in b: b:1 bb: bb:1; do
        for c in c: c:1 cc: cc:1; do
            printf '%s\n%s\n%s\n' $a $b $c >"$mail"
            sed 's/.*://' "$mail" >"$expected"
            sed 's/:.*/}/; s/^/%{/' "$mail" >"$format"
            run_prog scan -form "$format" -file "$mail" >"$actual" ||
            exit 1
            check "$expected" "$actual"
            rm -f "$mail" "$format"
        done
    done
done

exit $failed
