+# usually behave like "head -n 1"
a
ret: 0
+# never consume more than one line
1
2
ret: 0
+# add a newline
+abc
+ret: 1
+# print one newline on empty input
ret: 1
+# add a newline, return 1 when EOF
+xyz
+ret: 1
+# print one newline on empty input, return 1 when EOF
+
+ret: 1
+# large line of zero bytes
+00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
+*
+00100000 0a |.|
+00100001
+ret: 0
ts_init "$*"
ts_check_test_command "$TS_CMD_LINE"
+ts_check_test_command "$TS_CMD_HEXDUMP"
-# usually behave like "head -n 1"
+ts_log '# usually behave like "head -n 1"'
printf "a\nb\n" |
- $TS_CMD_LINE > $TS_OUTPUT 2>&1
+ $TS_CMD_LINE >> $TS_OUTPUT 2>&1
echo "ret: $?" >> $TS_OUTPUT
-# never consume more than one line
+ts_log '# never consume more than one line'
printf "1\n2\n" |
($TS_CMD_LINE && $TS_CMD_LINE) >> $TS_OUTPUT 2>&1
echo "ret: $?" >> $TS_OUTPUT
-# always print one newline, return 1 on EOF
+ts_log '# add a newline'
+printf "abc" |
+ $TS_CMD_LINE >> $TS_OUTPUT 2>&1
+echo "ret: $?" >> $TS_OUTPUT
+
+ts_log '# print one newline on empty input'
+printf "" |
+ $TS_CMD_LINE >> $TS_OUTPUT 2>&1
+echo "ret: $?" >> $TS_OUTPUT
+
+ts_log '# add a newline, return 1 when EOF'
+(printf "xyz" && cat </dev/null) |
+ $TS_CMD_LINE >> $TS_OUTPUT 2>&1
+echo "ret: $?" >> $TS_OUTPUT
+
+ts_log '# print one newline on empty input, return 1 when EOF'
$TS_CMD_LINE </dev/null >> $TS_OUTPUT 2>&1
echo "ret: $?" >> $TS_OUTPUT
+ts_log '# large line of zero bytes'
+dd if=/dev/zero bs=1k count=1k 2>/dev/null |
+ $TS_CMD_LINE line | $TS_CMD_HEXDUMP -C >> $TS_OUTPUT 2>&1
+echo "ret: $?" >> $TS_OUTPUT
+
ts_finalize