summaryrefslogtreecommitdiff
path: root/tests/misc
diff options
context:
space:
mode:
authorPádraig Brady <P@draigBrady.com>2015-06-23 22:48:25 +0100
committerPádraig Brady <P@draigBrady.com>2015-06-24 17:03:59 +0100
commit60c8e31d9201f10295cfdcfd2d15893f9682083b (patch)
treee3120ba36f30b691cfab27af0790b38c3882d9be /tests/misc
parentfc6825b231b43c12738fb65a9309cdecb67f6833 (diff)
downloadcoreutils-60c8e31d9201f10295cfdcfd2d15893f9682083b.tar.xz
seq: use consistent output format with hex integers
* src/seq.c (scan_arg): Set precision to 0 for hex constants (while avoiding hex floats). This will use then use the fast path for these arguments. Note we also set the precision of inf to 0 here, which ensures we use consistent precision on output where possible. * tests/misc/seq-precision.sh: Add corresponding test cases.
Diffstat (limited to 'tests/misc')
-rwxr-xr-xtests/misc/seq-precision.sh26
1 files changed, 25 insertions, 1 deletions
diff --git a/tests/misc/seq-precision.sh b/tests/misc/seq-precision.sh
index 9ba601446..e6a2bd7b8 100755
--- a/tests/misc/seq-precision.sh
+++ b/tests/misc/seq-precision.sh
@@ -19,7 +19,8 @@
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
print_ver_ seq
-# Integer only. Before v8.24 this would switch output format
+# Integer only. Before v8.24 these would switch output format
+
seq 999999 inf | head -n2 > out || fail=1
printf "%s\n" 999999 1000000 > exp || framework_failure_
compare exp out || fail=1
@@ -34,4 +35,27 @@ for i in $(seq 100); do
compare exp out || fail=1
done
+seq 0xF423F 0xF4240 > out || fail=1
+printf "%s\n" 999999 1000000 > exp || framework_failure_
+compare exp out || fail=1
+
+# Ensure consistent precision for inf
+seq 1 .1 inf | head -n2 > out || fail=1
+printf "%s\n" 1.0 1.1 > exp || framework_failure_
+compare exp out || fail=1
+
+# Ensure standard output methods with inf start
+seq inf inf | head -n2 | uniq > out || fail=1
+test "$(wc -l < out)" = 1 || fail=1
+
+# Ensure auto precision for hex float
+seq 1 0x1p-1 2 > out || fail=1
+printf "%s\n" 1 1.5 2 > exp || framework_failure_
+compare exp out || fail=1
+
+# Ensure consistent precision for hex
+seq 1 .1 0x2 | head -n2 > out || fail=1
+printf "%s\n" 1.0 1.1 > exp || framework_failure_
+compare exp out || fail=1
+
Exit $fail