Exercise %a without depending on a particular hex form: many
valid representations of the same value exist. Round-trip through
%.10f and check the 0x/0X prefix. Fold into printf.sh rather than
a separate test file.

Suggested by Pádraig Brady.

Signed-off-by: Iván Ezequiel Rodriguez <[email protected]>
---
 tests/printf/printf.sh | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/tests/printf/printf.sh b/tests/printf/printf.sh
index ad47868..305f5c1 100755
--- a/tests/printf/printf.sh
+++ b/tests/printf/printf.sh
@@ -148,5 +148,10 @@ $prog '%.70000f' 1 > out || fail=1
 test "$(wc -c < out)" = 70002 || fail=1
 test "$(tr -d 0 < out)" = '1.' || fail=1
 
+# %a hex-float: round-trip rather than matching a particular hex form
+# (many valid representations of the same value exist).
+fv=0.0009765625
+test $($prog '%.10f' $($prog %a $fv)) = $fv || fail=1
+$prog %a $fv | grep '^0[xX]' || fail=1
 
 Exit $fail
-- 
2.43.0


Reply via email to