Commit | Line | Data |
---|---|---|
970ed795 EL |
1 | /****************************************************************************** |
2 | * Copyright (c) 2000-2014 Ericsson Telecom AB | |
3 | * All rights reserved. This program and the accompanying materials | |
4 | * are made available under the terms of the Eclipse Public License v1.0 | |
5 | * which accompanies this distribution, and is available at | |
6 | * http://www.eclipse.org/legal/epl-v10.html | |
7 | ******************************************************************************/ | |
8 | module str_to_OK { //^In TTCN-3 module `str_to_OK':// | |
9 | ||
10 | type component PDTestComponent {}; | |
11 | ||
12 | ||
13 | /*--- STR2BIT --------------------------------------------------*/ | |
14 | ||
15 | const bitstring s2bcon := str2bit("") | |
16 | modulepar bitstring s2bpar := s2bcon | |
17 | modulepar bitstring s2bpar1 := str2bit("000000" & "" & "111111") | |
18 | const bitstring s2bcon2 := str2bit(substr("000000111111",0,6) & "" & substr("000000111111",6,6)) | |
19 | modulepar bitstring s2bpar2 := str2bit(substr("000000111111",0,6) & "" & substr("000000111111",6,6)) | |
20 | modulepar bitstring s2bpar3 := str2bit(("000000" <@ lengthof(s2bcon2)/2) & "" & ("111111" @> lengthof(s2bcon2)/2)) | |
21 | ||
22 | testcase str_to_bit() runs on PDTestComponent{ | |
23 | ||
24 | ||
25 | if ((s2bpar == str2bit("")) | |
26 | and (s2bpar == ''B)) | |
27 | {setverdict(pass);} | |
28 | else {setverdict(fail, __LINE__);} | |
29 | ||
30 | if ((s2bpar1 == str2bit("000000" & "" & "111111")) | |
31 | and (s2bpar1 == '000000111111'B)) | |
32 | {setverdict(pass);} | |
33 | else {setverdict(fail, __LINE__);} | |
34 | ||
35 | if ((s2bpar2 == str2bit(substr("000000111111",0,6) & "" & substr("000000111111",6,6))) | |
36 | and (s2bpar2 == '000000111111'B)) | |
37 | {setverdict(pass);} | |
38 | else {setverdict(fail, __LINE__);} | |
39 | ||
40 | if ((s2bpar3 == str2bit(("000000" <@ lengthof(s2bpar2)/2) & "" & ("111111" @> lengthof(s2bpar2)/2))) | |
41 | and (s2bpar3 == '000000111111'B)) | |
42 | {setverdict(pass);} | |
43 | else {setverdict(fail, __LINE__);} | |
44 | ||
45 | ||
46 | var integer j | |
47 | var charstring cc := "" | |
48 | var bitstring bb := ''B | |
49 | ||
50 | for (j:=0; j<64; j:=j+1) { | |
51 | cc := cc & bit2str(int2bit(j,j)) | |
52 | bb := bb & int2bit(j,j) | |
53 | if (bb == str2bit(cc)) | |
54 | {setverdict(pass);} | |
55 | else {setverdict(fail, __LINE__);} | |
56 | } | |
57 | ||
58 | } | |
59 | ||
60 | /*--- STR2FLOAT --------------------------------------------------*/ | |
61 | ||
62 | //const float s2fcon := str2float("") | |
63 | const float s2fcon := str2float("0.0") | |
64 | modulepar float s2fpar := str2float("0.0") | |
65 | modulepar float s2fpar1 := str2float("12345678901.0") | |
66 | modulepar float s2fpar2 := str2float("000000000000" & "12345678901.0") //In module parameter definition// \ | |
67 | //In default value// //In the operand of operation `str2float\(\)'// \ | |
68 | //warning: Leading zero digit was detected and ignored in the mantissa of the operand of operation `str2float\(\)'// | |
69 | modulepar float s2fpar3 := str2float("-12" & "345678901.0") | |
70 | modulepar float s2fpar4 := str2float("1.234E3") | |
71 | //modulepar float s2fpar5 := str2float("1.234-3") | |
72 | modulepar float s2fpar5 := str2float("1.234") | |
73 | //modulepar float s2fpar6 := str2float("1,234E3") | |
74 | modulepar float s2fpar6 := str2float("1.0") | |
75 | //modulepar float s2fpar7 := str2float("--234") | |
76 | ||
77 | // HL67862 | |
78 | modulepar float s2fpar7 := str2float("1"); | |
79 | modulepar float s2fpar7m:= str2float("-1"); | |
80 | modulepar float s2fpar8m:= str2float("-1."); | |
81 | modulepar float s2fpar8 := str2float("1."); | |
82 | modulepar float s2fpar9 := str2float("+001"); //In module parameter definition// \ | |
83 | //In default value// //In the operand of operation `str2float\(\)'// \ | |
84 | //warning: Leading zero digit was detected and ignored in the mantissa of the operand of operation `str2float\(\)'// | |
85 | modulepar float s2fpar10:= str2float("+001."); //In module parameter definition// \ | |
86 | //In default value// //In the operand of operation `str2float\(\)'// \ | |
87 | //warning: Leading zero digit was detected and ignored in the mantissa of the operand of operation `str2float\(\)'// | |
88 | modulepar float s2fpar11:= str2float("-0"); | |
89 | modulepar float s2fpar12:= str2float("-0."); | |
90 | modulepar float s2fpar13:= str2float("-0.0"); | |
91 | ||
92 | ||
93 | ||
94 | // modulepar prevents constant folding | |
95 | modulepar charstring s2fmp_str := "0.0" | |
96 | modulepar charstring s2fmp1_str := "12345678901.0" | |
97 | modulepar charstring s2fmp2_str := "000000000000" & "12345678901.0" | |
98 | modulepar charstring s2fmp3_str := "-12" & "345678901.0" | |
99 | modulepar charstring s2fmp4_str := "1.234E3" | |
100 | //modulepar charstring s2fmp5_str := "1.234-3" | |
101 | modulepar charstring s2fmp5_str := "1.234" | |
102 | //modulepar charstring s2fmp6_str := "1,234E3" | |
103 | modulepar charstring s2fmp6_str := "1.0" | |
104 | //modulepar charstring s2fmp7_str := "--234" | |
105 | ||
106 | // HL67862 | |
107 | modulepar charstring s2fmp7_str := "1"; | |
108 | modulepar charstring s2fmp7m_str:= "-1"; | |
109 | modulepar charstring s2fmp8m_str:= "-1."; | |
110 | modulepar charstring s2fmp8_str := "1."; | |
111 | modulepar charstring s2fmp9_str := "+001"; | |
112 | modulepar charstring s2fmp10_str:= "+001."; | |
113 | modulepar charstring s2fmp11_str:= "-0"; | |
114 | modulepar charstring s2fmp12_str:= "-0."; | |
115 | modulepar charstring s2fmp13_str:= "-0.0"; | |
116 | ||
117 | ||
118 | //modulepar float s2fmp := str2float("") | |
119 | modulepar float s2fmp := str2float("0.0") | |
120 | modulepar float s2fmp1 := str2float("12345678901.0") | |
121 | modulepar float s2fmp2 := str2float("000000000000" & "12345678901.0") //In module parameter definition// \ | |
122 | //In default value// //In the operand of operation `str2float\(\)'// \ | |
123 | //warning: Leading zero digit was detected and ignored in the mantissa of the operand of operation `str2float\(\)'// | |
124 | modulepar float s2fmp3 := str2float("-12" & "345678901.0") | |
125 | modulepar float s2fmp4 := str2float("1.234E3") | |
126 | //modulepar float s2fmp5 := str2float("1.234-3") | |
127 | modulepar float s2fmp5 := str2float("1.234") | |
128 | //modulepar float s2fmp6 := str2float("1,234E3") | |
129 | modulepar float s2fmp6 := str2float("1.0") | |
130 | //modulepar float s2fmp7 := str2float("--234") | |
131 | ||
132 | // HL67862 | |
133 | modulepar float s2fmp7 := str2float("1"); | |
134 | modulepar float s2fmp7m:= str2float("-1"); | |
135 | modulepar float s2fmp8m:= str2float("-1."); | |
136 | modulepar float s2fmp8 := str2float("1."); | |
137 | modulepar float s2fmp9 := str2float("+001"); //In module parameter definition// \ | |
138 | //In default value// //In the operand of operation `str2float\(\)'// \ | |
139 | //warning: Leading zero digit was detected and ignored in the mantissa of the operand of operation `str2float\(\)'// | |
140 | modulepar float s2fmp10:= str2float("+001."); //In module parameter definition// \ | |
141 | //In default value// //In the operand of operation `str2float\(\)'// \ | |
142 | //warning: Leading zero digit was detected and ignored in the mantissa of the operand of operation `str2float\(\)'// | |
143 | modulepar float s2fmp11:= str2float("-0"); | |
144 | modulepar float s2fmp12:= str2float("-0."); | |
145 | modulepar float s2fmp13:= str2float("-0.0"); | |
146 | ||
147 | ||
148 | ||
149 | testcase str_to_float() runs on PDTestComponent{ //In testcase definition// | |
150 | ||
151 | // compile-time | |
152 | if ((s2fpar == str2float("0.0")) | |
153 | and (s2fpar == 0.0)) | |
154 | {setverdict(pass);} | |
155 | else {setverdict(fail, __LINE__);} | |
156 | ||
157 | if ((s2fpar1 == str2float("12345678901.0")) | |
158 | and (s2fpar1 == 12345678901.0)) | |
159 | {setverdict(pass);} | |
160 | else {setverdict(fail, __LINE__);} | |
161 | ||
162 | if ((s2fpar2 == str2float("000000000000" & "12345678901.0")) //In if statement// \ | |
163 | //In the left operand of operation `and'// \ | |
164 | //In the right operand of operation `=='// \ | |
165 | //In the operand of operation `str2float\(\)'// \ | |
166 | //warning: Leading zero digit was detected and ignored in the mantissa of the operand of operation `str2float\(\)'// | |
167 | and (s2fpar2 == 12345678901.0)) | |
168 | {setverdict(pass);} | |
169 | else {setverdict(fail, __LINE__);} | |
170 | ||
171 | if ((s2fpar3 == str2float("-12" & "345678901.0")) | |
172 | and (s2fpar3 == -12345678901.0)) | |
173 | {setverdict(pass);} | |
174 | else {setverdict(fail, __LINE__);} | |
175 | ||
176 | if ((s2fpar4 == str2float("1.234E3")) | |
177 | and (s2fpar4 == 1234.0)) | |
178 | {setverdict(pass);} | |
179 | else {setverdict(fail, __LINE__);} | |
180 | ||
181 | if ((s2fpar5 == str2float("1.234")) | |
182 | and (s2fpar5 == 1.234)) | |
183 | {setverdict(pass);} | |
184 | else {setverdict(fail, __LINE__);} | |
185 | ||
186 | if ((s2fpar6 == str2float("1.0")) | |
187 | and (s2fpar6 == 1.0)) | |
188 | {setverdict(pass);} | |
189 | else {setverdict(fail, __LINE__);} | |
190 | ||
191 | if ((s2fpar7 == str2float("1" )) | |
192 | and (s2fpar7 == 1.0)) | |
193 | {setverdict(pass);} | |
194 | else {setverdict(fail, __LINE__);} | |
195 | ||
196 | if ((s2fpar7m== str2float("-1" )) | |
197 | and (s2fpar7m==-1.0)) | |
198 | {setverdict(pass);} | |
199 | else {setverdict(fail, __LINE__);} | |
200 | ||
201 | if ((s2fpar8m== str2float("-1." )) | |
202 | and (s2fpar8m==-1.0)) | |
203 | {setverdict(pass);} | |
204 | else {setverdict(fail, __LINE__);} | |
205 | ||
206 | if ((s2fpar8 == str2float("1." )) | |
207 | and (s2fpar8 == 1.0)) | |
208 | {setverdict(pass);} | |
209 | else {setverdict(fail, __LINE__);} | |
210 | ||
211 | if ((s2fpar9 == str2float("+001" )) //In if statement// \ | |
212 | //In the left operand of operation `and'// \ | |
213 | //In the right operand of operation `=='// \ | |
214 | //In the operand of operation `str2float\(\)'// \ | |
215 | //warning: Leading zero digit was detected and ignored in the mantissa of the operand of operation `str2float\(\)'// | |
216 | and (s2fpar9 == 1.0)) | |
217 | {setverdict(pass);} | |
218 | else {setverdict(fail, __LINE__);} | |
219 | ||
220 | if ((s2fpar10== str2float("+001.")) //In if statement// \ | |
221 | //In the left operand of operation `and'// \ | |
222 | //In the right operand of operation `=='// \ | |
223 | //In the operand of operation `str2float\(\)'// \ | |
224 | //warning: Leading zero digit was detected and ignored in the mantissa of the operand of operation `str2float\(\)'// | |
225 | and (s2fpar10== 1.0)) | |
226 | {setverdict(pass);} | |
227 | else {setverdict(fail, __LINE__);} | |
228 | ||
229 | if ((s2fpar11== str2float("-0" )) | |
230 | and (s2fpar11==-0.0)) | |
231 | {setverdict(pass);} | |
232 | else {setverdict(fail, __LINE__);} | |
233 | ||
234 | if ((s2fpar12== str2float("-0." )) | |
235 | and (s2fpar12== -0.0)) | |
236 | {setverdict(pass);} | |
237 | else {setverdict(fail, __LINE__);} | |
238 | ||
239 | if ((s2fpar13== str2float("-0.0" )) | |
240 | and (s2fpar13== -0.0)) | |
241 | {setverdict(pass);} | |
242 | else {setverdict(fail, __LINE__);} | |
243 | // run-time | |
244 | if ((s2fmp == str2float(s2fmp_str)) | |
245 | and (s2fmp == 0.0)) | |
246 | {setverdict(pass);} | |
247 | else {setverdict(fail, __LINE__);} | |
248 | ||
249 | if ((s2fmp1 == str2float(s2fmp1_str)) | |
250 | and (s2fmp1 == 12345678901.0)) | |
251 | {setverdict(pass);} | |
252 | else {setverdict(fail, __LINE__);} | |
253 | ||
254 | if ((s2fmp2 == str2float("000000000000" & "12345678901.0")) //In if statement// \ | |
255 | //In the left operand of operation `and'// \ | |
256 | //In the right operand of operation `=='// \ | |
257 | //In the operand of operation `str2float\(\)'// \ | |
258 | //warning: Leading zero digit was detected and ignored in the mantissa of the operand of operation `str2float\(\)'// | |
259 | and (s2fmp2 == 12345678901.0)) | |
260 | {setverdict(pass);} | |
261 | else {setverdict(fail, __LINE__);} | |
262 | ||
263 | if ((s2fmp3 == str2float("-12" & "345678901.0")) | |
264 | and (s2fmp3 == -12345678901.0)) | |
265 | {setverdict(pass);} | |
266 | else {setverdict(fail, __LINE__);} | |
267 | ||
268 | if ((s2fmp4 == str2float(s2fmp4_str)) | |
269 | and (s2fmp4 == 1234.0)) | |
270 | {setverdict(pass);} | |
271 | else {setverdict(fail, __LINE__);} | |
272 | ||
273 | if ((s2fmp5 == str2float(s2fmp5_str)) | |
274 | and (s2fmp5 == 1.234)) | |
275 | {setverdict(pass);} | |
276 | else {setverdict(fail, __LINE__);} | |
277 | ||
278 | if ((s2fmp6 == str2float(s2fmp6_str)) | |
279 | and (s2fmp6 == 1.0)) | |
280 | {setverdict(pass);} | |
281 | else {setverdict(fail, __LINE__);} | |
282 | ||
283 | if ((s2fmp7 == str2float(s2fmp7_str)) | |
284 | and (s2fmp7 == 1.0)) | |
285 | {setverdict(pass);} | |
286 | else {setverdict(fail, __LINE__);} | |
287 | ||
288 | if ((s2fmp7m == str2float(s2fmp7m_str)) | |
289 | and (s2fmp7m ==-1.0)) | |
290 | {setverdict(pass);} | |
291 | else {setverdict(fail, __LINE__);} | |
292 | ||
293 | if ((s2fmp8m == str2float(s2fmp8m_str)) | |
294 | and (s2fmp8m ==-1.0)) | |
295 | {setverdict(pass);} | |
296 | else {setverdict(fail, __LINE__);} | |
297 | ||
298 | if ((s2fmp8 == str2float(s2fmp8_str)) | |
299 | and (s2fmp8 == 1.0)) | |
300 | {setverdict(pass);} | |
301 | else {setverdict(fail, __LINE__);} | |
302 | ||
303 | if ((s2fmp9 == str2float(s2fmp9_str)) | |
304 | and (s2fmp9 == 1.0)) | |
305 | {setverdict(pass);} | |
306 | else {setverdict(fail, __LINE__);} | |
307 | ||
308 | if ((s2fmp10 == str2float(s2fmp10_str)) | |
309 | and (s2fmp10 == 1.0)) | |
310 | {setverdict(pass);} | |
311 | else {setverdict(fail, __LINE__);} | |
312 | ||
313 | if ((s2fmp11 == str2float(s2fmp11_str)) | |
314 | and (s2fmp11 ==-0.0)) | |
315 | {setverdict(pass);} | |
316 | else {setverdict(fail, __LINE__);} | |
317 | ||
318 | if ((s2fmp12 == str2float(s2fmp12_str)) | |
319 | and (s2fmp12 == -0.0)) | |
320 | {setverdict(pass);} | |
321 | else {setverdict(fail, __LINE__);} | |
322 | ||
323 | if ((s2fmp13 == str2float(s2fmp13_str)) | |
324 | and (s2fmp13 == -0.0)) | |
325 | {setverdict(pass);} | |
326 | else {setverdict(fail, __LINE__);} | |
327 | } | |
328 | ||
329 | ||
330 | /*--- STR2HEX --------------------------------------------------*/ | |
331 | ||
332 | const hexstring s2hcon := str2hex("") | |
333 | modulepar hexstring s2hpar := s2hcon | |
334 | modulepar hexstring s2hpar1 := str2hex("000000" & "" & "111111") | |
335 | const hexstring s2hcon2 := str2hex(substr("000000111111",0,6) & "" & substr("000000111111",6,6)) | |
336 | modulepar hexstring s2hpar2 := s2hcon2 | |
337 | modulepar hexstring s2hpar3 := str2hex(("000000" <@ lengthof(s2hcon2)/2) & "" & ("111111" @> lengthof(s2hcon2)/2)) | |
338 | ||
339 | testcase str_to_hex() runs on PDTestComponent{ | |
340 | ||
341 | ||
342 | if ((s2hpar == str2hex("")) | |
343 | and (s2hpar == ''H)) | |
344 | {setverdict(pass);} | |
345 | else {setverdict(fail, __LINE__);} | |
346 | ||
347 | if ((s2hpar1 == str2hex("000000" & "" & "111111")) | |
348 | and (s2hpar1 == '000000111111'H)) | |
349 | {setverdict(pass);} | |
350 | else {setverdict(fail, __LINE__);} | |
351 | ||
352 | if ((s2hpar2 == str2hex(substr("000000111111",0,6) & "" & substr("000000111111",6,6))) | |
353 | and (s2hpar2 == '000000111111'H)) | |
354 | {setverdict(pass);} | |
355 | else {setverdict(fail, __LINE__);} | |
356 | ||
357 | if ((s2hpar3 == str2hex(("000000" <@ lengthof(s2hpar2)/2) & "" & ("111111" @> lengthof(s2hpar2)/2))) | |
358 | and (s2hpar3 == '000000111111'H)) | |
359 | {setverdict(pass);} | |
360 | else {setverdict(fail, __LINE__);} | |
361 | ||
362 | ||
363 | var integer j | |
364 | var charstring cc := "" | |
365 | var hexstring hh := ''H | |
366 | ||
367 | for (j:=0; j<32; j:=j+1) { | |
368 | cc := cc & hex2str(int2hex(j,j)) | |
369 | hh := hh & int2hex(j,j) | |
370 | if (hh == str2hex(cc)) | |
371 | {setverdict(pass);} | |
372 | else {setverdict(fail, __LINE__);} | |
373 | } | |
374 | ||
375 | } | |
376 | ||
377 | /*--- STR2INT --------------------------------------------------*/ | |
378 | ||
379 | const integer s2icon := str2int("0") | |
380 | modulepar integer s2ipar := s2icon | |
381 | modulepar integer s2ipar1 := str2int("" & "1234567890") | |
382 | modulepar integer s2ipar2 := str2int("12" & "34567890") | |
383 | modulepar integer s2ipar3 := str2int("0000000000000000000000" & "1234567890") //In module parameter definition// \ | |
384 | //In default value// //In the operand of operation `str2int\(\)'// \ | |
385 | //warning: Leading zero digit was detected and ignored in the operand of operation `str2int\(\)'// | |
386 | modulepar integer s2ipar4 := str2int("-12" & "34567890") | |
387 | //modulepar integer s2ipar5 := str2int("12ap") | |
388 | modulepar integer s2ipar5 := str2int("12") | |
389 | //modulepar integer s2ipar6 := str2int("ap") | |
390 | modulepar integer s2ipar6 := str2int("1234567891011121314151617181920") | |
391 | modulepar integer s2ipar7 := str2int("-1234567891011121314151617181920") | |
392 | modulepar integer s2ipar8 := str2int("+1"); | |
393 | modulepar integer s2ipar9 := str2int("01"); //In module parameter definition// \ | |
394 | //In default value// //In the operand of operation `str2int\(\)'// \ | |
395 | //warning: Leading zero digit was detected and ignored in the operand of operation `str2int\(\)'// | |
396 | modulepar integer s2ipar10 := str2int("+01"); //In module parameter definition// \ | |
397 | //In default value// //In the operand of operation `str2int\(\)'// \ | |
398 | //warning: Leading zero digit was detected and ignored in the operand of operation `str2int\(\)'// | |
399 | modulepar integer s2ipar11 := str2int("-01"); //In module parameter definition// \ | |
400 | //In default value// //In the operand of operation `str2int\(\)'// \ | |
401 | //warning: Leading zero digit was detected and ignored in the operand of operation `str2int\(\)'// | |
402 | ||
403 | testcase str_to_int() runs on PDTestComponent{ //In testcase definition// | |
404 | var charstring vv := "1234567891011121314151617181920" | |
405 | var charstring vv1 := "-1234567891011121314151617181920" | |
406 | var integer ii := str2int("1234567891011121314151617181920") | |
407 | var integer ii1 := str2int("-1234567891011121314151617181920") | |
408 | ||
409 | if ((s2ipar == str2int("0")) | |
410 | and (s2ipar == 0)) | |
411 | {setverdict(pass);} | |
412 | else {setverdict(fail, __LINE__);} | |
413 | if ((s2ipar8 == str2int("+1")) | |
414 | and (s2ipar8 == 1)) | |
415 | {setverdict(pass);} | |
416 | else {setverdict(fail, __LINE__);} | |
417 | if ((s2ipar9 == str2int("01")) //In if statement// \ | |
418 | //In the left operand of operation `and'// \ | |
419 | //In the right operand of operation `=='// \ | |
420 | //In the operand of operation `str2int\(\)'// \ | |
421 | //warning: Leading zero digit was detected and ignored in the operand of operation `str2int\(\)'// | |
422 | and (s2ipar9 == 1)) | |
423 | {setverdict(pass);} | |
424 | else {setverdict(fail, __LINE__);} | |
425 | if ((s2ipar10 == str2int("+01")) //In if statement// \ | |
426 | //In the left operand of operation `and'// \ | |
427 | //In the right operand of operation `=='// \ | |
428 | //In the operand of operation `str2int\(\)'// \ | |
429 | //warning: Leading zero digit was detected and ignored in the operand of operation `str2int\(\)'// | |
430 | and (s2ipar10 == 1)) | |
431 | {setverdict(pass);} | |
432 | else {setverdict(fail, __LINE__);} | |
433 | if ((s2ipar11 == str2int("-01")) //In if statement// \ | |
434 | //In the left operand of operation `and'// \ | |
435 | //In the right operand of operation `=='// \ | |
436 | //In the operand of operation `str2int\(\)'// \ | |
437 | //warning: Leading zero digit was detected and ignored in the operand of operation `str2int\(\)'// | |
438 | and (s2ipar11 == -1)) | |
439 | {setverdict(pass);} | |
440 | else {setverdict(fail, __LINE__);} | |
441 | if ((s2ipar1 == str2int("" & "1234567890")) | |
442 | and (s2ipar1 == 1234567890)) | |
443 | {setverdict(pass);} | |
444 | else {setverdict(fail, __LINE__);} | |
445 | if ((s2ipar2 == str2int("12" & "34567890")) | |
446 | and (s2ipar2 == 1234567890)) | |
447 | {setverdict(pass);} | |
448 | else {setverdict(fail, __LINE__);} | |
449 | if ((s2ipar3 == str2int("00000000000000000000000" & "1234567890")) //In if statement// \ | |
450 | //In the left operand of operation `and'// \ | |
451 | //In the right operand of operation `=='// \ | |
452 | //In the operand of operation `str2int\(\)'// \ | |
453 | //warning: Leading zero digit was detected and ignored in the operand of operation `str2int\(\)'// | |
454 | and (s2ipar3 == 1234567890)) | |
455 | {setverdict(pass);} | |
456 | else {setverdict(fail, __LINE__);} | |
457 | if ((s2ipar4 == str2int("-12" & "34567890")) | |
458 | and (s2ipar4 == -1234567890)) | |
459 | {setverdict(pass);} | |
460 | else {setverdict(fail, __LINE__);} | |
461 | if ((s2ipar5 == str2int("12")) | |
462 | and (s2ipar5 == 12)) | |
463 | {setverdict(pass);} | |
464 | else {setverdict(fail, __LINE__);} | |
465 | /* Compiler error: | |
466 | if ((s2ipar6 == str2int("ap")) | |
467 | and (s2ipar6 == 0)) | |
468 | {setverdict(pass);} | |
469 | else {setverdict(fail, __LINE__);} | |
470 | */ | |
471 | // Compile time evaluation. (Positive/negative.) | |
472 | if ((str2int("1234567891011121314151617181920") == s2ipar6) | |
473 | and (s2ipar6 == str2int("1234567891011121314151617181920"))) | |
474 | {setverdict(pass);} | |
475 | else {setverdict(fail, __LINE__);} | |
476 | if ((str2int("-1234567891011121314151617181920") == s2ipar7) | |
477 | and (s2ipar7 == str2int("-1234567891011121314151617181920"))) | |
478 | {setverdict(pass);} | |
479 | else {setverdict(fail, __LINE__);} | |
480 | /* compile-time | |
481 | if ((int2str(str2int("1234567891011121314151617181920")) == "1234567891011121314151617181920") | |
482 | and ("1234567891011121314151617181920" == int2str(str2int("1234567891011121314151617181920")))) | |
483 | {setverdict(pass);} | |
484 | else {setverdict(fail, __LINE__);} | |
485 | if ((int2str(str2int("-1234567891011121314151617181920")) == "-1234567891011121314151617181920") | |
486 | and ("-1234567891011121314151617181920" == int2str(str2int("-1234567891011121314151617181920")))) | |
487 | {setverdict(pass);} | |
488 | else {setverdict(fail, __LINE__);} | |
489 | */ | |
490 | if ((str2int("1234567891011121314151617181920") - 10 == s2ipar6 - 10) | |
491 | and (s2ipar6 + 10 == str2int("1234567891011121314151617181920") + 10)) | |
492 | {setverdict(pass);} | |
493 | else {setverdict(fail, __LINE__);} | |
494 | if ((str2int("-1234567891011121314151617181920") + 10 == s2ipar7 + 10) | |
495 | and (s2ipar7 - 10 == str2int("-1234567891011121314151617181920") - 10)) | |
496 | {setverdict(pass);} | |
497 | else {setverdict(fail, __LINE__);} | |
498 | // Run-time evaluation. (Positive/negative.) | |
499 | if ((str2int(vv) == ii) | |
500 | and (ii == str2int("1234567891011121314151617181920"))) | |
501 | {setverdict(pass);} | |
502 | else {setverdict(fail, __LINE__);} | |
503 | if ((str2int("-1234567891011121314151617181920") == ii1) | |
504 | and (ii1 == str2int(vv1))) | |
505 | {setverdict(pass);} | |
506 | else {setverdict(fail, __LINE__);} | |
507 | if ((int2str(str2int(vv)) == "1234567891011121314151617181920") | |
508 | and ("1234567891011121314151617181920" == int2str(str2int(vv)))) | |
509 | {setverdict(pass);} | |
510 | else {setverdict(fail, __LINE__);} | |
511 | if ((int2str(str2int(vv1)) == "-1234567891011121314151617181920") | |
512 | and ("-1234567891011121314151617181920" == int2str(str2int(vv1)))) | |
513 | {setverdict(pass);} | |
514 | else {setverdict(fail, __LINE__);} | |
515 | if ((str2int(vv) - 10 == ii - 10) | |
516 | and (ii + 10 == str2int("1234567891011121314151617181920") + 10)) | |
517 | {setverdict(pass);} | |
518 | else {setverdict(fail, __LINE__);} | |
519 | if ((str2int("-1234567891011121314151617181920") + 10 == ii1 + 10) | |
520 | and (ii1 - 10 == str2int(vv1) - 10)) | |
521 | {setverdict(pass);} | |
522 | else {setverdict(fail, __LINE__);} | |
523 | if ((str2int(vv) == -str2int(vv1)) | |
524 | and (str2int(vv1) == -str2int(vv))) | |
525 | {setverdict(pass);} | |
526 | else {setverdict(fail, __LINE__);} | |
527 | ||
528 | var integer j | |
529 | for (j:=1; j<10; j:=j+1) { | |
530 | if (str2int(substr("0123456789",0,j+1)) == (str2int(substr("0123456789",0,j))*10 + j)) | |
531 | {setverdict(pass);} | |
532 | else {setverdict(fail, __LINE__);} | |
533 | } | |
534 | } | |
535 | ||
536 | ||
537 | /*--- STR2OCT --------------------------------------------------*/ | |
538 | ||
539 | const octetstring s2ocon := str2oct("") | |
540 | modulepar octetstring s2opar := s2ocon | |
541 | modulepar octetstring s2opar1 := str2oct("000000" & "" & "111111") | |
542 | const octetstring s2ocon2 := str2oct(substr("000000111111",0,6) & "" & substr("000000111111",6,6)) | |
543 | modulepar octetstring s2opar2 := s2ocon2 | |
544 | modulepar octetstring s2opar3 := str2oct(("000000" <@ lengthof(s2ocon2)/2) & "" & ("111111" @> lengthof(s2ocon2)/2)) | |
545 | ||
546 | testcase str_to_oct() runs on PDTestComponent{ | |
547 | ||
548 | ||
549 | if ((s2opar == str2oct("")) | |
550 | and (s2opar == ''O)) | |
551 | {setverdict(pass);} | |
552 | else {setverdict(fail, __LINE__);} | |
553 | ||
554 | if ((s2opar1 == str2oct("000000" & "" & "111111")) | |
555 | and (s2opar1 == '000000111111'O)) | |
556 | {setverdict(pass);} | |
557 | else {setverdict(fail, __LINE__);} | |
558 | ||
559 | if ((s2opar2 == str2oct(substr("000000111111",0,6) & "" & substr("000000111111",6,6))) | |
560 | and (s2opar2 == '000000111111'O)) | |
561 | {setverdict(pass);} | |
562 | else {setverdict(fail, __LINE__);} | |
563 | ||
564 | if ((s2opar3 == str2oct(("000000" <@ lengthof(s2opar2)/2) & "" & ("111111" @> lengthof(s2opar2)/2))) | |
565 | and (s2opar3 == '000000111111'O)) | |
566 | {setverdict(pass);} | |
567 | else {setverdict(fail, __LINE__);} | |
568 | ||
569 | ||
570 | var integer j | |
571 | var charstring cc := "" | |
572 | var octetstring oo := ''O | |
573 | ||
574 | for (j:=0; j<64; j:=j+1) { | |
575 | cc := cc & oct2str(int2oct(j,j)) | |
576 | oo := oo & int2oct(j,j) | |
577 | if (oo == str2oct(cc)) | |
578 | {setverdict(pass);} | |
579 | else {setverdict(fail, __LINE__);} | |
580 | } | |
581 | ||
582 | } | |
583 | ||
584 | ||
585 | control { | |
586 | execute (str_to_bit()); | |
587 | execute (str_to_float()); | |
588 | execute (str_to_hex()); | |
589 | execute (str_to_int()); | |
590 | execute (str_to_oct()); | |
591 | } | |
592 | ||
593 | } |