-# $OpenBSD: regress.sh,v 1.3 2016/08/06 14:41:14 tb Exp $
+# $OpenBSD: regress.sh,v 1.4 2016/08/06 15:46:33 tb Exp $
# $FreeBSD: head/usr.bin/jot/tests/regress.sh 208728 2010-06-02 07:47:29Z brian $
JOT=${JOT-jot}
REGRESSION_START(`pwd`)
-REGRESSION_TEST([[x]], [[${JOT} -w "%X" -s , 100 1 200]])
+# A: test all 16 possibilities for reps, begin, end, s with omissions
REGRESSION_TEST([[hhhh]], [[${JOT} 50 20 120 2]])
REGRESSION_TEST([[hhhd]], [[${JOT} 50 20 120 -]])
REGRESSION_TEST([[hhdh]], [[${JOT} 50 20 - 2]])
REGRESSION_TEST([[ddhd]], [[${JOT} - - 120 -]])
REGRESSION_TEST([[dddh]], [[${JOT} - - - 2]])
REGRESSION_TEST([[dddd]], [[${JOT} - - - -]])
+
+# B: same as A, but different numbers, only 12 because of 4 duplicates
REGRESSION_TEST([[hhhh2]], [[${JOT} 30 20 160 2]])
REGRESSION_TEST([[hhhd2]], [[${JOT} 30 20 160 -]])
REGRESSION_TEST([[hhdh2]], [[${JOT} 30 20 - 2]])
REGRESSION_TEST([[dhhh2]], [[${JOT} - 20 160 2]])
REGRESSION_TEST([[dhhd2]], [[${JOT} - 20 160 -]])
REGRESSION_TEST([[ddhh2]], [[${JOT} - - 160 2]])
+REGRESSION_TEST([[ddhd2]], [[${JOT} - - 160 -]])
+
+# C: reverse roles of begin and end in A.
+REGRESSION_TEST([[hhhh3]], [[${JOT} 50 120 20 -2]])
+REGRESSION_TEST([[hhhd3]], [[${JOT} 50 120 20 -]])
+REGRESSION_TEST([[hhdh3]], [[${JOT} 50 120 - -2]])
+REGRESSION_TEST([[hhdd3]], [[${JOT} 50 120 - -]])
+REGRESSION_TEST([[hdhh3]], [[${JOT} 50 - 20 -2]])
+REGRESSION_TEST([[hdhd3]], [[${JOT} 50 - 20 -]])
+REGRESSION_TEST([[dhhh3]], [[${JOT} - 120 20 -2]])
+REGRESSION_TEST([[dhhd3]], [[${JOT} - 120 20 -]])
+REGRESSION_TEST([[dhdh3]], [[${JOT} - 120 - -2]])
+REGRESSION_TEST([[dhdd3]], [[${JOT} - 120 - -]])
+REGRESSION_TEST([[ddhh3]], [[${JOT} - - 20 -2]])
+REGRESSION_TEST([[ddhd3]], [[${JOT} - - 20 -]])
+
+# D: reverse roles of begin and end in B.
+REGRESSION_TEST([[hhhh4]], [[${JOT} 30 160 20 -2]])
+REGRESSION_TEST([[hhhd4]], [[${JOT} 30 160 20 -]])
+REGRESSION_TEST([[hhdh4]], [[${JOT} 30 160 - -2]])
+REGRESSION_TEST([[hhdd4]], [[${JOT} 30 160 - -]])
+REGRESSION_TEST([[hdhh4]], [[${JOT} 30 - 20 -2]])
+REGRESSION_TEST([[hdhd4]], [[${JOT} 30 - 20 -]])
+REGRESSION_TEST([[dhhh4]], [[${JOT} - 160 20 -2]])
+REGRESSION_TEST([[dhhd4]], [[${JOT} - 160 20 -]])
+
+# E: what happens if begin and end are equal?
+REGRESSION_TEST([[dbbd]], [[${JOT} - 10 10 -]])
+REGRESSION_TEST([[hbbd]], [[${JOT} 15 10 10 -]])
+REGRESSION_TEST([[dbbh]], [[${JOT} - 10 10 2]])
+REGRESSION_TEST([[hbbh]], [[${JOT} 15 10 10 2]])
+
+# F: random output
+# rand1 and rand2 test coverage (10000 is way too big: 200 should be enough)
REGRESSION_TEST([[rand1]], [[${JOT} -r 10000 0 9 | sort -u]])
REGRESSION_TEST([[rand2]], [[${JOT} -r 10000 9 0 | sort -u]])
# rdhhh and rhdhh test if begin and ender are set to the default with jot -r
REGRESSION_TEST([[rdhhh]], [[${JOT} -r 100 - 10 2 2>/dev/null | sort -n | head -1]])
REGRESSION_TEST([[rhdhh]], [[${JOT} -r 100 90 - 2 2>/dev/null | sort -n | tail -1]])
+
+# G: Examples from the FreeBSD manual
REGRESSION_TEST([[n21]], [[${JOT} 21 -1 1.00]])
REGRESSION_TEST([[ascii]], [[${JOT} -c 128 0]])
REGRESSION_TEST([[xaa]], [[${JOT} -w xa%c 26 a]])
REGRESSION_TEST([[block]], [[${JOT} -b x 512]])
REGRESSION_TEST([[tabs]], [[${JOT} -s, - 10 132 4]])
REGRESSION_TEST([[grep]], [[${JOT} -s "" -b . 80]])
+
+# H: various format strings
REGRESSION_TEST([[wf]], [[${JOT} -w "a%.1fb" 10]])
REGRESSION_TEST([[we]], [[${JOT} -w "a%eb" 10]])
REGRESSION_TEST([[wwe]], [[${JOT} -w "a%-15eb" 10]])
REGRESSION_TEST([[wp4]], [[${JOT} -w "%%d%d%%d%%" 10]])
REGRESSION_TEST([[wp5]], [[${JOT} -w ftp://www.example.com/pub/uploaded%%20files/disk%03d.iso 10]])
REGRESSION_TEST([[wp6]], [[${JOT} -w "%d%" 10]])
+REGRESSION_TEST([[x]], [[${JOT} -w "%X" -s , 100 1 200]])
-# test some of the examples in the jot(1) man page
+# I: Examples from the OpenBSD manual
REGRESSION_TEST([[man1]], [[${JOT} 6 1 10 0.5]])
REGRESSION_TEST([[man2]], [[${JOT} -p 1 6 1 10 0.5]])
REGRESSION_TEST([[man3]], [[${JOT} -p 0 6 .9999999999 10 0.5]])