Lindenii Project Forge
Login

scdoc

scdoc mirror for performance testing
Commit info
ID
9b8ecbe992cc9218d56a36d277d69f1541c20735
Author
Drew DeVault <sir@cmpwn.com>
Author date
Sun, 13 May 2018 20:14:01 -0400
Committer
Drew DeVault <sir@cmpwn.com>
Committer date
Sun, 13 May 2018 20:14:01 -0400
Actions
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
}