1 dnl Copyright © 2015, 2021-2024 Nick Bowler
3 dnl License WTFPL2: Do What The Fuck You Want To Public License, version 2.
4 dnl This is free software: you are free to do what the fuck you want to.
5 dnl There is NO WARRANTY, to the extent permitted by law.
7 AT_BANNER([Binary packing functions])
9 TEST_TAP_SIMPLE([signed unpacking], [packtests], [], [pack])
10 TEST_TAP_SIMPLE([unsigned unpacking], [packtestu], [], [pack])
11 TEST_TAP_SIMPLE([64-bit signed unpacking], [packtests64], [], [pack])
12 TEST_TAP_SIMPLE([64-bit unsigned unpacking], [packtestu64], [], [pack])
14 AT_BANNER([Help formatting functions])
16 AT_SETUP([help_print_desc])
19 AT_SKIP_IF([test ! -x "$builddir/t/helpdesc"])
22 [[this is the first line
23 this is the second line
24 this is the third line
28 sed -e '5,$s/^/ /' -e '6,$s/^/ /' \
30 -e '13s/^ *//' -e '14,$s/^/ /' \
31 test.txt test.txt test.txt test.txt >expout
33 AT_CHECK(["$builddir/t/helpdesc" 0 0 10 5 30 20 40 40 <test.txt],
36 AT_CHECK([AS_ECHO_N(["no trailing newline"]) |
37 "$builddir/t/helpdesc" 0 0], [0],
43 AT_SETUP([help_print_desc (empty description)])
46 AT_SKIP_IF([test ! -x "$builddir/t/helpdesc"])
48 AT_CHECK(["$builddir/t/helpdesc" 0 0 0 20 </dev/null], [0], [
51 AT_CHECK(["$builddir/t/helpdesc" 1 20 </dev/null], [0], [
56 AT_SETUP([help_print_optstring])
66 --hello-this-is-a-very-long-option
68 --hello-this-is-a-very-long-option 35
73 # Some very old printf implementations return 0 on success instead of the
74 # number of bytes written. The help_print_optstring function is not fully
75 # functional in this case. It should fallback to printing a newline and
76 # returning 0 so the overall --help output should be mostly acceptable.
78 # We verify that this indeed works properly by adjusting the expected
79 # output accordingly, but ...
80 AS_IF(["$builddir/t/printfchk" >/dev/null], [ancient_printf=false],
81 [[sed -n -e 's/ [0-9]*$//' -e '/^ *-/p' -e 's/^ *-.*/ 0/p' expout >expout.tmp
82 mv -f expout.tmp expout
85 AT_CHECK([m4_join([ ],
86 ["$builddir/t/helpopt"],
91 [--quux '@<:@ARG@:>@'],
92 [--quux -q '@<:@ARG@:>@'],
93 [--hello-this-is-a-very-long-option 20],
94 [--hello-this-is-a-very-long-option 50],
96 [--flagged -f \&])], [0], [expout])
98 # ... we ultimately skip the test so there's an indication (other than an
99 # outright failure) that the function is not working completely.
100 AT_SKIP_IF([$ancient_printf])
104 AT_SETUP([help_print_optstring (getopt_long_only)])
114 -hello-this-is-a-very-long-option
116 -hello-this-is-a-very-long-option 34
121 # Some very old printf implementations return 0 on success instead of the
122 # number of bytes written. The help_print_optstring function is not fully
123 # functional in this case. It should fallback to printing a newline and
124 # returning 0 so the overall --help output should be mostly acceptable.
126 # We verify that this indeed works properly by adjusting the expected
127 # output accordingly, but ...
128 AS_IF(["$builddir/t/printfchk" >/dev/null], [ancient_printf=false],
129 [[sed -n -e 's/ [0-9]*$//' -e '/^ *-/p' -e 's/^ *-.*/ 0/p' expout >expout.tmp
130 mv -f expout.tmp expout
133 AT_CHECK([m4_join([ ],
134 ["$builddir/t/helpopt2"],
139 [--quux '@<:@ARG@:>@'],
140 [--quux -q '@<:@ARG@:>@'],
141 [--hello-this-is-a-very-long-option 20],
142 [--hello-this-is-a-very-long-option 50],
144 [--flagged -f \&])], [0], [expout])
146 # ... we ultimately skip the test so there's an indication (other than an
147 # outright failure) that the function is not working completely.
148 AT_SKIP_IF([$ancient_printf])
152 AT_SETUP([help_print_optstring (NLS fullwidth/halfwidth)])
153 AT_KEYWORDS([help nls])
155 AT_SKIP_IF([test ! -x "$builddir/t/helpopt3"])
156 TEST_UTF8_LOCALE([locale_utf8])
158 # Avoid some deficient shell parsers barfing on UTF-8 sequences by
159 # generating them this way using octal escapes.
161 zenkaku = "--\345\205\250\350\247\222";
162 hankaku = "--\357\276\212\357\276\235\357\275\266\357\275\270"
164 print zenkaku, hankaku >"args"
166 print " " zenkaku "\t" "7"
167 print " " hankaku "\t" "7"
168 }' >expout </dev/null
170 AT_CHECK([LC_ALL=$locale_utf8 xargs "$builddir/t/helpopt3" <args],
175 AT_BANNER([Miscellaneous functions])
177 TEST_TAP_SIMPLE([copyright_symbol], [copysym], [], [])