1 # Test for the strtonum module
3 ## Testing str_to_uint(.) (It is supoposed that uint is 4 bytes integer)
6 Run: ../obj/ucw/strtonum-test '0o+-_' '0o100_000xc' | grep '^i'
10 Run: ../obj/ucw/strtonum-test '0O+-_' '0100_000xc' | grep '^i'
14 Run: ../obj/ucw/strtonum-test '0O+-_' '00000000778' | grep '^i'
18 Run: ../obj/ucw/strtonum-test '0XoB+-_' '4_294_967_295xcyv' | grep '^i'
22 Run: ../obj/ucw/strtonum-test '0XoB+-_' '4_294_967_296xc' | grep '^e'
23 Out: e[Numeric overflow]
26 Run: ../obj/ucw/strtonum-test '0XoBt+-_' '4_294_967_296xc' | grep '^h'
30 Run: ../obj/ucw/strtonum-test '0XoBt+-_' '4_294_967_296xc' | grep '^b'
34 Run: ../obj/ucw/strtonum-test '0XoBt+-_' '0x__4_' | grep '^i'
38 Run: ../obj/ucw/strtonum-test '0XoBt+-_' '0x__4_' | grep '^b'
42 Run: ../obj/ucw/strtonum-test '0XoBt+-_' '0xXW' | grep '^e'
43 Out: e[Number contains no digits]
46 Run: ../obj/ucw/strtonum-test '0XoBt+-_' '0xXW' | grep '^b'
50 Run: ../obj/ucw/strtonum-test '0oBt+-_' '0xXW' | grep '^i'
54 Run: ../obj/ucw/strtonum-test '0oBt+-_' '0xXW' | grep '^b'
58 Run: ../obj/ucw/strtonum-test '0oBt+-_W' '0xXW' | grep '^e'
59 Out: e[Invalid character]
62 Run: ../obj/ucw/strtonum-test '0oBt+-_W' '0xXW' | grep '^b'
66 Run: ../obj/ucw/strtonum-test '0Bs+-_' '2_147_483_647xxx' | grep '^i'
70 Run: ../obj/ucw/strtonum-test '0Bs+-_' '2_147_483_647xxx' | grep '^i'
74 Run: ../obj/ucw/strtonum-test '0Bs+-_' '2_147_483_648xxx' | grep '^e'
75 Out: e[Numeric overflow]
78 Run: ../obj/ucw/strtonum-test '0Bs+-_' '-2_147_483_648xxx' | grep '^i'
82 Run: ../obj/ucw/strtonum-test '0Bs+-_' '-2_147_483_649xxx' | grep '^e'
83 Out: e[Numeric overflow]
86 Run: ../obj/ucw/strtonum-test '0Bts+-_' '2_147_483_648xxx' | grep '^i'
90 Run: ../obj/ucw/strtonum-test '0Bts+-_' '-2_147_483_649xxx' | grep '^i'
94 Run: ../obj/ucw/strtonum-test '0Bts+-_' '-2_147_483_649xxx' | grep '^i'
98 Run: ../obj/ucw/strtonum-test '0X+-' '0xABCDEFxxx' | grep '^h'
102 Run: ../obj/ucw/strtonum-test '0X+-_' '0x00_AB_CD_EFxxx' | grep '^h'
106 Run: ../obj/ucw/strtonum-test '0Xs+-_' '-0x00AB_CDEFxxx' | grep '^h'
110 Run: ../obj/ucw/strtonum-test '0XBs+-_' '-0x00AB_CDEFxxx' | grep '^h'
114 Run: ../obj/ucw/strtonum-test '0B+-_' '0B1111_0000_1000_0101_1010xxx' | grep '^h'
118 Run: ../obj/ucw/strtonum-test '0+-_' '0B1111_0000_1000_0101_1010xxx' | grep '^b'
122 Run: ../obj/ucw/strtonum-test '0o+-_' '0o70105xxx' | grep '^i'
126 Run: ../obj/ucw/strtonum-test '0os+-_' '-0o70105xxx' | grep '^i'
130 Run: ../obj/ucw/strtonum-test '0os+-_' '-0o___________xxx' | grep '^e'
131 Out: e[Number contains no digits]
134 Run: ../obj/ucw/strtonum-test '2+-_' '10578ABCG' | grep '^i'
138 Run: ../obj/ucw/strtonum-test '2s+-_' '-10578ABCG' | grep '^i'
142 Run: ../obj/ucw/strtonum-test '8+-_' '10578ABCG' | grep '^i'
146 Run: ../obj/ucw/strtonum-test '8s+-_' '-10578ABCG' | grep '^i'
150 Run: ../obj/ucw/strtonum-test '0+-_' '10578ABCG' | grep '^i'
154 Run: ../obj/ucw/strtonum-test '0s+-_' '-10578ABCG' | grep '^i'
158 Run: ../obj/ucw/strtonum-test 'h+-_' '10578ABCG' | grep '^i'
162 Run: ../obj/ucw/strtonum-test 'hs+-_' '-10578ABCG' | grep '^i'
165 ## Testing str_to_uintmax(.) (It is supoposed that uintmax_t is 8 bytes integer)
167 Run: ../obj/ucw/strtonum-test 'h+-_' 'FFFF_FFFF_ffff_ffFF' | grep '^H'
168 Out: Hffffffffffffffff
171 Run: ../obj/ucw/strtonum-test 'h+-_' 'FFFF_FFFF_ffff_ffFF' | grep '^I'
172 Out: I18446744073709551615
175 Run: ../obj/ucw/strtonum-test '0t+-_' '1844674407370000009551616' | grep '^I'
176 Out: I18446744073709551615
179 Run: ../obj/ucw/strtonum-test '0+-_' '18446744073709551616' | grep '^E'
180 Out: E[Numeric overflow]
183 Run: ../obj/ucw/strtonum-test '0+-_' '18446744073709551614' | grep '^H'
184 Out: Hfffffffffffffffe
187 Run: ../obj/ucw/strtonum-test '0s+-_' '9223372036854775807L' | grep '^I'
188 Out: I9223372036854775807
191 Run: ../obj/ucw/strtonum-test '0s+-_' '9223372036854775806L' | grep '^I'
192 Out: I9223372036854775806
195 Run: ../obj/ucw/strtonum-test '0st+-_' '92233720368547758000000L' | grep '^I'
196 Out: I9223372036854775807
199 Run: ../obj/ucw/strtonum-test '0s+-_' '9223372036854775808L' | grep '^E'
200 Out: E[Numeric overflow]
203 Run: ../obj/ucw/strtonum-test '0s+-_' '-9223372036854775808L' | grep '^I'
204 Out: I-9223372036854775808
207 Run: ../obj/ucw/strtonum-test '0s+-_' '-9223372036854775807L' | grep '^I'
208 Out: I-9223372036854775807
211 Run: ../obj/ucw/strtonum-test '0st+-_' '-9223372036854775800000L' | grep '^I'
212 Out: I-9223372036854775808
215 Run: ../obj/ucw/strtonum-test '0s+-_' '-9223372036854775809L' | grep '^E'
216 Out: E[Numeric overflow]