Lindenii Project Forge
Add some more tests
#!/bin/sh . test/lib.sh begin "Fail on ###" scdoc <<EOF >/dev/null test(8) ### this is not a valid heading EOF end 1 begin "Expects a space after #" scdoc <<EOF >/dev/null test(8) #needs a space there EOF end 1 begin "Emits a new section" scdoc <<EOF | grep '^\.SH HEADER' >/dev/null test(8) # HEADER EOF end 0 begin "Emits a new subsection" scdoc <<EOF | grep '^\.SS HEADER' >/dev/null test(8) ## HEADER EOF end 0
#!/bin/sh . test/lib.sh begin "Disallows nested formatting" scdoc <<EOF >/dev/null test(8) _hello *world*_ EOF end 1 begin "Emits bold text" scdoc <<EOF | grep '^hello \\fBworld\\fR' >/dev/null test(8) hello *world* EOF end 0 begin "Emits underlined text" scdoc <<EOF | grep '^hello \\fIworld\\fR' >/dev/null test(8) hello _world_ EOF end 0 begin "Handles escaped characters" scdoc <<EOF | grep '^hello _world_' >/dev/null test(8) hello \_world\_ EOF end 0
printf '== %s\n' "$0" trap "printf '\n'" EXIT
begin() { printf '%-40s' "$1" } scdoc() { ./scdoc "$@" 2>&1 } end() { if [ $? -ne "$1" ] then printf 'FAIL\n' else printf 'OK\n' fi }