-# $OpenBSD: Makefile,v 1.46 2021/03/09 17:38:24 martijn Exp $
+# $OpenBSD: Makefile,v 1.47 2023/06/12 20:19:45 millert Exp $
SUBDIR+= apply
SUBDIR+= basename bc
SUBDIR+= nc
SUBDIR+= openssl
SUBDIR+= rev
-SUBDIR+= sdiff sed signify snmp sort
+SUBDIR+= sdiff sed seq signify snmp sort
SUBDIR+= tsort
SUBDIR+= ul
SUBDIR+= wc
--- /dev/null
+# $OpenBSD: Makefile,v 1.1 2023/06/12 20:19:45 millert Exp $
+
+SEQ?= /usr/bin/seq
+
+seqtest:
+ sh ${.CURDIR}/$@.sh ${SEQ} $@.out
+ diff ${.CURDIR}/$@.expected $@.out
--- /dev/null
+Test 1.1: check for invalid format string
+seq: invalid format string: `foo'
+
+Test 1.2: check for valid format string
+bar1.000000
+bar2.000000
+bar3.000000
+
+Test 1.3: check for invalid increment
+seq: zero decrement
+
+Test 1.4: check for first > last
+seq: needs negative decrement
+
+Test 1.5: check for increment mismatch
+seq: needs positive increment
+
+Test 1.6: check for increment mismatch
+seq: needs negative decrement
+
+Test 2.0: single argument (0)
+1
+0
+
+Test 2.1: single argument (1)
+1
+
+Test 2.2: single argument (-1)
+1
+0
+-1
+
+Test 2.3: two arguments (1, 1)
+1
+
+Test 2.3: two arguments (1, 2)
+1
+2
+
+Test 2.3: two arguments (1, -2)
+1
+0
+-1
+-2
+
+Test 3.0: check for missing element due to rounding
+1
+1.1
+1.2
+
+Test 3.1: check for missing element due to rounding
+0
+1e-06
+2e-06
+3e-06
+
+Test 3.2: check for extra element due to rounding
+0.1
+1.09
+
+Test 3.3: check for extra element due to rounding check
+1.05e+06
--- /dev/null
+#!/bin/sh
+# $OpenBSD: seqtest.sh,v 1.1 2023/06/12 20:19:45 millert Exp $
+#
+# Public domain, 2023, Todd C. Miller <millert@openbsd.org>
+#
+# Usage: seqtest.sh [seq_bin log_file]
+#
+# If no log file is specified, seq.out is used.
+
+run_tests()
+{
+ SEQ=$1
+ LOG=$2
+ rm -f $LOG
+ exec >$LOG 2>&1
+
+ test_args;
+ test_simple;
+ test_rounding;
+}
+
+test_args()
+{
+ echo 'Test 1.1: check for invalid format string'
+ ${SEQ} -f foo 3
+
+ echo
+ echo 'Test 1.2: check for valid format string'
+ ${SEQ} -f bar%f 3
+
+ echo
+ echo 'Test 1.3: check for invalid increment'
+ ${SEQ} 1 0 1
+
+ echo
+ echo 'Test 1.4: check for first > last'
+ ${SEQ} 1 .1 -1
+
+ echo
+ echo 'Test 1.5: check for increment mismatch'
+ ${SEQ} 0 -0.1 1
+
+ echo
+ echo 'Test 1.6: check for increment mismatch'
+ ${SEQ} 1 0.1 0
+}
+
+test_simple()
+{
+ echo
+ echo 'Test 2.0: single argument (0)'
+ ${SEQ} 0
+
+ echo
+ echo 'Test 2.1: single argument (1)'
+ ${SEQ} 1
+
+ echo
+ echo 'Test 2.2: single argument (-1)'
+ ${SEQ} -1
+
+ echo
+ echo 'Test 2.3: two arguments (1, 1)'
+ ${SEQ} 1 1
+
+ echo
+ echo 'Test 2.3: two arguments (1, 2)'
+ ${SEQ} 1 2
+
+ echo
+ echo 'Test 2.3: two arguments (1, -2)'
+ ${SEQ} 1 -2
+}
+
+test_rounding()
+{
+ echo
+ echo 'Test 3.0: check for missing element due to rounding'
+ ${SEQ} 1 0.1 1.2
+
+ echo
+ echo 'Test 3.1: check for missing element due to rounding'
+ ${SEQ} 0 0.000001 0.000003
+
+ echo
+ echo 'Test 3.2: check for extra element due to rounding'
+ ${SEQ} 0.1 .99 1.99
+
+ echo
+ echo 'Test 3.3: check for extra element due to rounding check'
+ ${SEQ} 1050000 1050000
+}
+
+run_tests ${1:-seq} ${2:-seq.out}