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