]> mj.ucw.cz Git - libucw.git/blob - ucw/strtonum-test.t
Build: Fixed few compilation warnings/errors.
[libucw.git] / ucw / strtonum-test.t
1 # Test for the strtonum module
2
3 ## Testing str_to_uns(.) (It is supoposed that uns is 4 bytes integer)
4
5 # 1
6 Run:    ../obj/ucw/strtonum-test '0o+-_' '0o100_000xc' | grep '^i'
7 Out:    i32768
8
9 # 2
10 Run:    ../obj/ucw/strtonum-test '0O+-_' '0100_000xc' | grep '^i'
11 Out:    i32768
12
13 # 3
14 Run:    ../obj/ucw/strtonum-test '0O+-_' '00000000778' | grep '^i'
15 Out:    i63
16
17 # 4
18 Run:    ../obj/ucw/strtonum-test '0XoB+-_' '4_294_967_295xcyv' | grep '^i'
19 Out:    i4294967295
20
21 # 5
22 Run:    ../obj/ucw/strtonum-test '0XoB+-_' '4_294_967_296xc' | grep '^e'
23 Out:    e[Numeric overflow]
24
25 # 6
26 Run:    ../obj/ucw/strtonum-test '0XoBt+-_' '4_294_967_296xc' | grep '^h'
27 Out:    hffffffff
28
29 # 7
30 Run:    ../obj/ucw/strtonum-test '0XoBt+-_' '4_294_967_296xc' | grep '^b'
31 Out:    b13:0x78
32
33 # 8
34 Run:    ../obj/ucw/strtonum-test '0XoBt+-_' '0x__4_' | grep '^i'
35 Out:    i4
36
37 # 9
38 Run:    ../obj/ucw/strtonum-test '0XoBt+-_' '0x__4_' | grep '^b'
39 Out:    b6:0x0
40
41 # 10
42 Run:    ../obj/ucw/strtonum-test '0XoBt+-_' '0xXW' | grep '^e'
43 Out:    e[Number contains no digits]
44
45 # 11
46 Run:    ../obj/ucw/strtonum-test '0XoBt+-_' '0xXW' | grep '^b'
47 Out:    b2:0x58
48
49 # 12
50 Run:    ../obj/ucw/strtonum-test '0oBt+-_' '0xXW' | grep '^i'
51 Out:    i0
52
53 # 13
54 Run:    ../obj/ucw/strtonum-test '0oBt+-_' '0xXW' | grep '^b'
55 Out:    b1:0x78
56
57 # 14
58 Run:    ../obj/ucw/strtonum-test '0oBt+-_W' '0xXW' | grep '^e'
59 Out:    e[Invalid character]
60
61 # 15
62 Run:    ../obj/ucw/strtonum-test '0oBt+-_W' '0xXW' | grep '^b'
63 Out:    b1:0x78
64
65 # 16
66 Run:    ../obj/ucw/strtonum-test '0Bs+-_' '2_147_483_647xxx' | grep '^i'
67 Out:    i2147483647
68
69 # 17
70 Run:    ../obj/ucw/strtonum-test '0Bs+-_' '2_147_483_647xxx' | grep '^i'
71 Out:    i2147483647
72
73 # 18
74 Run:    ../obj/ucw/strtonum-test '0Bs+-_' '2_147_483_648xxx' | grep '^e'
75 Out:    e[Numeric overflow]
76
77 # 19
78 Run:    ../obj/ucw/strtonum-test '0Bs+-_' '-2_147_483_648xxx' | grep '^i'
79 Out:    i-2147483648
80
81 # 20
82 Run:    ../obj/ucw/strtonum-test '0Bs+-_' '-2_147_483_649xxx' | grep '^e'
83 Out:    e[Numeric overflow]
84
85 # 21
86 Run:    ../obj/ucw/strtonum-test '0Bts+-_' '2_147_483_648xxx' | grep '^i'
87 Out:    i2147483647
88
89 # 22
90 Run:    ../obj/ucw/strtonum-test '0Bts+-_' '-2_147_483_649xxx' | grep '^i'
91 Out:    i-2147483648
92
93 # 23
94 Run:    ../obj/ucw/strtonum-test '0Bts+-_' '-2_147_483_649xxx' | grep '^i'
95 Out:    i-2147483648
96
97 # 24
98 Run:    ../obj/ucw/strtonum-test '0X+-' '0xABCDEFxxx' | grep '^h'
99 Out:    habcdef
100
101 # 25
102 Run:    ../obj/ucw/strtonum-test '0X+-_' '0x00_AB_CD_EFxxx' | grep '^h'
103 Out:    habcdef
104
105 # 26
106 Run:    ../obj/ucw/strtonum-test '0Xs+-_' '-0x00AB_CDEFxxx' | grep '^h'
107 Out:    hff543211
108
109 # 27
110 Run:    ../obj/ucw/strtonum-test '0XBs+-_' '-0x00AB_CDEFxxx' | grep '^h'
111 Out:    hff543211
112
113 # 28
114 Run:    ../obj/ucw/strtonum-test '0B+-_' '0B1111_0000_1000_0101_1010xxx' | grep '^h'
115 Out:    hf085a
116
117 # 29
118 Run:    ../obj/ucw/strtonum-test '0+-_' '0B1111_0000_1000_0101_1010xxx' | grep '^b'
119 Out:    b1:0x42
120
121 # 30
122 Run:    ../obj/ucw/strtonum-test '0o+-_' '0o70105xxx' | grep '^i'
123 Out:    i28741
124
125 # 31
126 Run:    ../obj/ucw/strtonum-test '0os+-_' '-0o70105xxx' | grep '^i'
127 Out:    i-28741
128
129 # 32
130 Run:    ../obj/ucw/strtonum-test '0os+-_' '-0o___________xxx' | grep '^e'
131 Out:    e[Number contains no digits]
132
133 # 33
134 Run:    ../obj/ucw/strtonum-test '2+-_' '10578ABCG' | grep '^i'
135 Out:    i2
136
137 # 34
138 Run:    ../obj/ucw/strtonum-test '2s+-_' '-10578ABCG' | grep '^i'
139 Out:    i-2
140
141 # 35
142 Run:    ../obj/ucw/strtonum-test '8+-_' '10578ABCG' | grep '^i'
143 Out:    i559
144
145 # 36
146 Run:    ../obj/ucw/strtonum-test '8s+-_' '-10578ABCG' | grep '^i'
147 Out:    i-559
148
149 # 37
150 Run:    ../obj/ucw/strtonum-test '0+-_' '10578ABCG' | grep '^i'
151 Out:    i10578
152
153 # 38
154 Run:    ../obj/ucw/strtonum-test '0s+-_' '-10578ABCG' | grep '^i'
155 Out:    i-10578
156
157 # 39
158 Run:    ../obj/ucw/strtonum-test 'h+-_' '10578ABCG' | grep '^i'
159 Out:    i274172604
160
161 # 40
162 Run:    ../obj/ucw/strtonum-test 'hs+-_' '-10578ABCG' | grep '^i'
163 Out:    i-274172604
164
165 ## Testing str_to_uintmax(.) (It is supoposed that uintmax_t is 8 bytes integer)
166 # 41
167 Run:    ../obj/ucw/strtonum-test 'h+-_' 'FFFF_FFFF_ffff_ffFF' | grep '^H'
168 Out:    Hffffffffffffffff
169
170 # 42
171 Run:    ../obj/ucw/strtonum-test 'h+-_' 'FFFF_FFFF_ffff_ffFF' | grep '^I'
172 Out:    I18446744073709551615
173
174 # 43
175 Run:    ../obj/ucw/strtonum-test '0t+-_' '1844674407370000009551616' | grep '^I'
176 Out:    I18446744073709551615
177
178 # 44
179 Run:    ../obj/ucw/strtonum-test '0+-_' '18446744073709551616' | grep '^E'
180 Out:    E[Numeric overflow]
181
182 # 45
183 Run:    ../obj/ucw/strtonum-test '0+-_' '18446744073709551614' | grep '^H'
184 Out:    Hfffffffffffffffe
185
186 # 46
187 Run:    ../obj/ucw/strtonum-test '0s+-_' '9223372036854775807L' | grep '^I'
188 Out:    I9223372036854775807
189
190 # 47
191 Run:    ../obj/ucw/strtonum-test '0s+-_' '9223372036854775806L' | grep '^I'
192 Out:    I9223372036854775806
193
194 # 48
195 Run:    ../obj/ucw/strtonum-test '0st+-_' '92233720368547758000000L' | grep '^I'
196 Out:    I9223372036854775807
197
198 # 49
199 Run:    ../obj/ucw/strtonum-test '0s+-_' '9223372036854775808L' | grep '^E'
200 Out:    E[Numeric overflow]
201
202 # 50
203 Run:    ../obj/ucw/strtonum-test '0s+-_' '-9223372036854775808L' | grep '^I'
204 Out:    I-9223372036854775808
205
206 # 51
207 Run:    ../obj/ucw/strtonum-test '0s+-_' '-9223372036854775807L' | grep '^I'
208 Out:    I-9223372036854775807
209
210 # 52
211 Run:    ../obj/ucw/strtonum-test '0st+-_' '-9223372036854775800000L' | grep '^I'
212 Out:    I-9223372036854775808
213
214 # 53
215 Run:    ../obj/ucw/strtonum-test '0s+-_' '-9223372036854775809L' | grep '^E'
216 Out:    E[Numeric overflow]
217