#!/bin/sh

# TODO: Move to a common file tests can source; need more framework...
failed=0
check() {
    diff -u $expected $actual
    if [ $? -ne 0 ]; then
        failed=$((failed + 1))
    fi
}

folders=$MH_TEST_DIR/Mail/.folders

expected=$MH_TEST_DIR/$$.expected
actual=$MH_TEST_DIR/$$.actual

# make second folder
cp -r $MH_TEST_DIR/Mail/inbox $MH_TEST_DIR/Mail/foo1
cp -r $MH_TEST_DIR/Mail/inbox $MH_TEST_DIR/Mail/foo2
# but only list inbox and foo2 in .folders, and sorted differently
cat > $folders <<EOF
inbox
foo2
EOF

# Add a sequence, which has no messages in it
echo empty: >>"$MH_TEST_DIR/Mail/foo2/.mh_sequences"

# test with the empty sequence
cat > $expected <<EOF
 total      0.
EOF
new empty > $actual 2>&1
check
new -folders $folders empty > $actual 2>&1
check

# test fnext/fprev with the empty sequence
> $expected
fnext empty > $actual 2>&1
check
fprev empty > $actual 2>&1
check

