commit 9b8ecbe992cc9218d56a36d277d69f1541c20735 parent 3227b18a354d82c3fbd76ac28c7b18796e8be1d4 Author: Drew DeVault <sir@cmpwn.com> Date: Sun, 13 May 2018 20:14:01 -0400 Add some more tests Diffstat:
A | test/heading | | | 34 | ++++++++++++++++++++++++++++++++++ |
A | test/inline-formatting | | | 34 | ++++++++++++++++++++++++++++++++++ |
M | test/lib.sh | | | 3 | +++ |
3 files changed, 71 insertions(+), 0 deletions(-)
diff --git a/test/heading b/test/heading @@ -0,0 +1,34 @@ +#!/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 diff --git a/test/inline-formatting b/test/inline-formatting @@ -0,0 +1,34 @@ +#!/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 diff --git a/test/lib.sh b/test/lib.sh @@ -1,3 +1,6 @@ +printf '== %s\n' "$0" +trap "printf '\n'" EXIT + begin() { printf '%-40s' "$1" }