handle environmental variables when we create folders dynamically to
[deliverable/titan.core.git] / regression_test / templateCharstr / TtemplateCharstr.ttcn
1 /******************************************************************************
2 * Copyright (c) 2000-2016 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 * Contributors:
9 * Balasko, Jeno
10 * Baranyi, Botond
11 * Godar, Marton
12 * Kovacs, Ferenc
13 * Raduly, Csaba
14 * Szabados, Kristof
15 * Szabo, Janos Zoltan – initial implementation
16 * Pandi, Krisztian
17 *
18 ******************************************************************************/
19 module TtemplateCharstr {
20 type component templateCharstr_mycomp {};
21 type record templateCharstr_rec {
22 charstring x1,
23 charstring x2,
24 charstring x3 optional };
25 template templateCharstr_rec templateCharstr_tSpec :={ //specific values
26 x1:="00AA",
27 x2:="01AA",
28 x3:="10AA" };
29 template templateCharstr_rec templateCharstr_tList :={ //specific value and value list
30 x1:="00AA",
31 x2:=("01AA","01AB","11AC"),
32 x3:="10AA" };
33 template templateCharstr_rec templateCharstr_tComp :={ //specific value and compl. list
34 x1:="00AA",
35 x2:=complement ("11","0A","1BC0"),
36 x3:="10AA" };
37 template templateCharstr_rec templateCharstr_tOmit :={ //omitting values
38 x1:="00AA",
39 x2:="01AA",
40 x3:=omit } ;
41 template templateCharstr_rec templateCharstr_tAny :={ //specific and any value
42 x1:="00AA",
43 x2:="01AA",
44 x3:=? } ;
45 template templateCharstr_rec templateCharstr_tAnyorNone :={ //specific and AnyorNone value
46 x1:="00AA",
47 x2:="01AA",
48 x3:=* };
49 template templateCharstr_rec templateCharstr_tLength1 :={ //specific value and fix length
50 x1:="00AA",
51 x2:="01AA",
52 x3:=* length(3) };
53 template templateCharstr_rec templateCharstr_tLength2 :={ //specific value and length (range)
54 x1:="00AA",
55 x2:="01AA",
56 x3:=? length(2..4) };
57 template templateCharstr_rec templateCharstr_tLength3 :={ //specific value and length (range, infinity)
58 x1:="00AA",
59 x2:="01AA",
60 x3:=? length(2..infinity) };
61 template templateCharstr_rec templateCharstr_tIfpresent :={ //specific value and ifpresent
62 x1:="00AA",
63 x2:="01AA",
64 x3:="10AA" ifpresent };
65 template templateCharstr_rec templateCharstr_tLengthIfp :={ //specific value and fix length and ifpresent
66 x1:="00AA",
67 x2:="01AA",
68 x3:=? length(3) ifpresent};
69 template templateCharstr_rec templateCharstr_tAnyEl :={ //specific value and any element inside value
70 x1:="00AA",
71 x2:="01AA",
72 x3:= pattern "10?" } ;
73 template templateCharstr_rec templateCharstr_tAnyorNoneEl :={ //specific value and Any number of elements or none inside value
74 x1:="00AA",
75 x2:="01AA",
76 x3:= pattern "10*" };
77 template templateCharstr_rec templateCharstr_tRange1 :={ //specific value and Range
78 x1:="1",
79 x2:=("2" .."4"),
80 x3:="3" };
81 template templateCharstr_rec templateCharstr_tRange2 :={ //specific value and Range
82 x1:="1",
83 x2:=("2" .. "4"),
84 x3:="3" };
85 template templateCharstr_rec templateCharstr_tRange3 :={ //specific value and Range
86 x1:="1",
87 x2:=("3" .. int2char(127)),
88 x3:="3" };
89 template templateCharstr_rec templateCharstr_tRange4 :={ //specific value and Range
90 x1:="1",
91 x2:=(int2char(0) .. "4"),
92 x3:="3" };
93 template templateCharstr_rec templateCharstr_tRepeat := {
94 x1:= pattern "6#3", // precisely 3
95 x2:= pattern "6#(,)", // any number
96 x3:= pattern "6#(3)" }; // precisely 3
97 template templateCharstr_rec templateCharstr_tRepeatFull := {
98 x1:= pattern "6#(3,)", // at least 3
99 x2:= pattern "6#(,3)", // at most 3
100 x3:= pattern "6#(3,3)" }; // precisely 3
101 template templateCharstr_rec templateCharstr_tPattern := {
102 x1 := pattern "abc?xyz",
103 x2 := pattern @nocase "abc?xyz",
104 x3 := pattern @nocase "abc*xyz" };
105
106 testcase templateCharstrSpec() runs on templateCharstr_mycomp {
107 var templateCharstr_rec x1,x2; //specific value
108 x1:={ x1:="00AA", x2:="01AA", x3:="10AA" };
109 x2:={ x1:="00BC", x2:="01AA", x3:="10AA" };
110 //match
111 if (match(x1,templateCharstr_tSpec)) {setverdict(pass);}
112 else {setverdict(fail);}
113 //no match
114 if (not(match(x2,templateCharstr_tSpec))) {setverdict(pass);}
115 else {setverdict(fail);}
116 }
117
118 testcase templateCharstrList() runs on templateCharstr_mycomp {
119 var templateCharstr_rec x1,x2,x3; //value list
120 x1:={ x1:="00AA", x2:="01AA", x3:="10AA" };
121 x2:={ x1:="00AA", x2:="00", x3:="10AA" };
122 x3:={ x1:="1D", x2:="01AA", x3:="10AA" };
123 //match
124 if (match(x1,templateCharstr_tList)) {setverdict(pass);}
125 else {setverdict(fail);}
126 //no match: out of list
127 if (not(match(x2,templateCharstr_tList))) {setverdict(pass);}
128 else {setverdict(fail);}
129 //no match: other field
130 if (not(match(x3,templateCharstr_tList))) {setverdict(pass);}
131 else {setverdict(fail);}
132 }
133
134 testcase templateCharstrComp() runs on templateCharstr_mycomp {
135 var templateCharstr_rec x1,x2,x3; //complemented list
136 x1:={ x1:="00AA", x2:="01AA", x3:="10AA" };
137 x2:={ x1:="00AA", x2:="0A", x3:="10AA" };
138 x3:={ x1:="11AA", x2:="01AA", x3:="10AA" };
139 //match
140 if (match(x1,templateCharstr_tComp)) {setverdict(pass);}
141 else {setverdict(fail);}
142 //no match: in the list
143 if (not(match(x2,templateCharstr_tComp))) {setverdict(pass);}
144 else {setverdict(fail);}
145 //no match: other field
146 if (not(match(x3,templateCharstr_tComp))) {setverdict(pass);}
147 else {setverdict(fail);}
148 }
149
150 testcase templateCharstrOmit() runs on templateCharstr_mycomp {
151 var templateCharstr_rec x1,x2,x3; //omitting value
152 x1:={ x1:="00AA", x2:="01AA", x3:=omit };
153 x2:={ x1:="00AA", x2:="01AA", x3:="AB" };
154 x3:={ x1:="00DE", x2:="01AA", x3:=omit };
155 //match
156 if (match(x1,templateCharstr_tOmit)) {setverdict(pass);}
157 else {setverdict(fail);}
158 //no match: not omitted
159 if (not(match(x2,templateCharstr_tOmit))) {setverdict(pass);}
160 else {setverdict(fail);}
161 //no match: other field
162 if (not(match(x3,templateCharstr_tOmit))) {setverdict(pass);}
163 else {setverdict(fail);}
164 }
165
166 testcase templateCharstrAny() runs on templateCharstr_mycomp {
167 var templateCharstr_rec x1,x2,x3; //any value
168 x1:={ x1:="00AA", x2:="01AA", x3:="ABCD" };
169 x2:={ x1:="00AA", x2:="01AA", x3:=omit };
170 x3:={ x1:="0A", x2:="01AA", x3:="ABCD" };
171 //match
172 if (match(x1,templateCharstr_tAny)) {setverdict(pass);}
173 else {setverdict(fail);}
174 //no match: field omitted
175 if (not(match(x2,templateCharstr_tAny))) {setverdict(pass);}
176 else {setverdict(fail);}
177 //no match: other field
178 if (not(match(x3,templateCharstr_tAny))) {setverdict(pass);}
179 else {setverdict(fail);}
180 }
181
182 testcase templateCharstrAnyorNone() runs on templateCharstr_mycomp {
183 var templateCharstr_rec x1,x2,x3; //AnyorNone value
184 x1:={ x1:="00AA", x2:="01AA", x3:=omit };
185 x2:={ x1:="00AA", x2:="01AA", x3:="10AB" };
186 x3:={ x1:="1C", x2:="01AA", x3:=omit };
187 //match: omitted
188 if (match(x1,templateCharstr_tAnyorNone)) {setverdict(pass);}
189 else {setverdict(fail);}
190 //match: value
191 if (match(x2,templateCharstr_tAnyorNone)) {setverdict(pass);}
192 else {setverdict(fail);}
193 //no match: other field
194 if (not(match(x3,templateCharstr_tAnyorNone))) {setverdict(pass);}
195 else {setverdict(fail);}
196 }
197
198 testcase templateCharstrLength1() runs on templateCharstr_mycomp {
199 var templateCharstr_rec x1,x2,x3,x4; //length (fix)
200 x1:={ x1:="00AA", x2:="01AA", x3:="abc" };
201 x2:={ x1:="00AA", x2:="01AA", x3:="abc" };
202 x3:={ x1:="00AA", x2:="01AA", x3:="1D" };
203 x4:={ x1:="001A", x2:="01AA", x3:="abc" };
204 //match: proper length
205 if (match(x1,templateCharstr_tLength1)) {setverdict(pass);}
206 else {setverdict(fail);}
207 //match: omitted
208 if (match(x2,templateCharstr_tLength1)) {setverdict(pass);}
209 else {setverdict(fail);}
210 // no match: not proper length
211 if (not(match(x3,templateCharstr_tLength1))) {setverdict(pass);}
212 else {setverdict(fail);}
213 //no match: other field
214 if (not(match(x4,templateCharstr_tLength1))) {setverdict(pass);}
215 else {setverdict(fail);}
216 }
217
218 testcase templateCharstrLength2() runs on templateCharstr_mycomp {
219 var templateCharstr_rec x1,x2,x3; //length (range)
220 x1:={ x1:="00AA", x2:="01AA", x3:="abcd" };
221 x2:={ x1:="00AA", x2:="01AA", x3:="a" };
222 x3:={ x1:="001A", x2:="01AA", x3:="abc" };
223 //match
224 if (match(x1,templateCharstr_tLength2)) {setverdict(pass);}
225 else {setverdict(fail);}
226 // no match: not proper length
227 if (not(match(x2,templateCharstr_tLength2))) {setverdict(pass);}
228 else {setverdict(fail);}
229 //no match: other field
230 if (not(match(x3,templateCharstr_tLength2))) {setverdict(pass);}
231 else {setverdict(fail);}
232 }
233
234 testcase templateCharstrLength3() runs on templateCharstr_mycomp {
235 var templateCharstr_rec x1,x2,x3; //length (range, infinity)
236 x1:={ x1:="00AA", x2:="01AA", x3:="abcd" };
237 x2:={ x1:="00AA", x2:="01AA", x3:="a" };
238 x3:={ x1:="001A", x2:="01AA", x3:="abc" };
239 //match
240 if (match(x1,templateCharstr_tLength3)) {setverdict(pass);}
241 else {setverdict(fail);}
242 // no match: not proper length
243 if (not(match(x2,templateCharstr_tLength3))) {setverdict(pass);}
244 else {setverdict(fail);}
245 //no match: other field
246 if (not(match(x3,templateCharstr_tLength3))) {setverdict(pass);}
247 else {setverdict(fail);}
248 }
249 testcase templateCharstrIfpresent() runs on templateCharstr_mycomp {
250 var templateCharstr_rec x1,x2,x3,x4; //ifpresent
251 x1:={ x1:="00AA", x2:="01AA", x3:="10AA" };
252 x2:={ x1:="00AA", x2:="01AA", x3:=omit };
253 x3:={ x1:="00AA", x2:="01AA", x3:="00AA" };
254 x4:={ x1:="00", x2:="01AA", x3:=omit };
255 //match: present and match
256 if (match(x1,templateCharstr_tIfpresent)) {setverdict(pass);}
257 else {setverdict(fail);}
258 //match: not present
259 if (match(x2,templateCharstr_tIfpresent)) {setverdict(pass);}
260 else {setverdict(fail);}
261 //no match: present and not match
262 if (not(match(x3,templateCharstr_tIfpresent))) {setverdict(pass);}
263 else {setverdict(fail);}
264 //no match: other field
265 if (not(match(x4,templateCharstr_tIfpresent))) {setverdict(pass);}
266 else {setverdict(fail);}
267 }
268
269 testcase templateCharstrLengthIfp() runs on templateCharstr_mycomp {
270 var templateCharstr_rec x1,x2,x3,x4; //length (fix), ifpresent
271 x1:={ x1:="00AA", x2:="01AA", x3:="abc" };
272 x2:={ x1:="00AA", x2:="01AA", x3:="abc" };
273 x3:={ x1:="00AA", x2:="01AA", x3:="1D" };
274 x4:={ x1:="001A", x2:="01AA", x3:="abc" };
275 //match: proper length
276 if (match(x1,templateCharstr_tLengthIfp)) {setverdict(pass);}
277 else {setverdict(fail);}
278 //match: omitted
279 if (match(x2,templateCharstr_tLengthIfp)) {setverdict(pass);}
280 else {setverdict(fail);}
281 // no match: not proper length
282 if (not(match(x3,templateCharstr_tLengthIfp))) {setverdict(pass);}
283 else {setverdict(fail);}
284 //no match: other field
285 if (not(match(x4,templateCharstr_tLengthIfp))) {setverdict(pass);}
286 else {setverdict(fail);}
287 }
288
289 testcase templateCharstrAnyEl() runs on templateCharstr_mycomp {
290 var templateCharstr_rec x1,x2,x3,x4,x5; //any element
291 x1:={ x1:="00AA", x2:="01AA", x3:="10a" };
292 x2:={ x1:="00AA", x2:="01AA", x3:="10" };
293 x3:={ x1:="00AA", x2:="01AA", x3:="10Aa" };
294 x4:={ x1:="00AA", x2:="01AA", x3:="12A" };
295 x5:={ x1:="0A", x2:="01AA", x3:="10a" };
296 //match
297 if (match(x1,templateCharstr_tAnyEl)) {setverdict(pass);}
298 else {setverdict(fail);}
299 //no match: no element
300 if (not(match(x2,templateCharstr_tAnyEl))) {setverdict(pass);}
301 else {setverdict(fail);}
302 //no match: two element
303 if (not(match(x3,templateCharstr_tAnyEl))) {setverdict(pass);}
304 else {setverdict(fail);}
305 //no match: wrong element
306 if (not(match(x4,templateCharstr_tAnyEl))) {setverdict(pass);}
307 else {setverdict(fail);}
308 //no match: other field
309 if (not(match(x5,templateCharstr_tAnyEl))) {setverdict(pass);}
310 else {setverdict(fail);}
311 }
312
313 testcase templateCharstrAnyorNoneEl() runs on templateCharstr_mycomp {
314 var templateCharstr_rec x1,x2,x3,x4,x5; //Any number of elements or none
315 x1:={ x1:="00AA", x2:="01AA", x3:="10" };
316 x2:={ x1:="00AA", x2:="01AA", x3:="10k" };
317 x3:={ x1:="00AA", x2:="01AA", x3:="10Aa" };
318 x4:={ x1:="00AA", x2:="01AA", x3:="11a" };
319 x5:={ x1:="1A", x2:="01AA", x3:="10a" };
320 //match: no element
321 if (match(x1,templateCharstr_tAnyorNoneEl)) {setverdict(pass);}
322 else {setverdict(fail);}
323 //match: one element
324 if (match(x2,templateCharstr_tAnyorNoneEl)) {setverdict(pass);}
325 else {setverdict(fail);}
326 //match: two element
327 if (match(x3,templateCharstr_tAnyorNoneEl)) {setverdict(pass);}
328 else {setverdict(fail);}
329 //no match: wrong element
330 if (not(match(x4,templateCharstr_tAnyorNoneEl))) {setverdict(pass);}
331 else {setverdict(fail);}
332 //no match: other field
333 if (not(match(x5,templateCharstr_tAnyorNoneEl))) {setverdict(pass);}
334 else {setverdict(fail);}
335 }
336
337
338 testcase templateCharstrRange1() runs on templateCharstr_mycomp {
339 var templateCharstr_rec x1,x2,x3; //Range ( .. )
340 x1:={ x1:="1", x2:="2", x3:="3" };
341 x2:={ x1:="1", x2:="5", x3:="3" };
342 x3:={ x1:="2", x2:="2", x3:="3" };
343 //match
344 if (match(x1,templateCharstr_tRange1)) {setverdict(pass);}
345 else {setverdict(fail);}
346 //no match: out of range
347 if (not(match(x2,templateCharstr_tRange1))) {setverdict(pass);}
348 else {setverdict(fail);}
349 //no match: other field
350 if (not(match(x3,templateCharstr_tRange1))) {setverdict(pass);}
351 else {setverdict(fail);}
352 }
353
354 testcase templateCharstrRange2() runs on templateCharstr_mycomp {
355 var templateCharstr_rec x1,x2,x3; //Range ( to )
356 x1:={ x1:="1", x2:="2", x3:="3" };
357 x2:={ x1:="1", x2:="5", x3:="3"};
358 x3:={ x1:="2", x2:="2", x3:="3" };
359 //match
360 if (match(x1,templateCharstr_tRange2)) {setverdict(pass);}
361 else {setverdict(fail);}
362 //no match: out of range
363 if (not(match(x2,templateCharstr_tRange2))) {setverdict(pass);}
364 else {setverdict(fail);}
365 //no match: other field
366 if (not(match(x3,templateCharstr_tRange2))) {setverdict(pass);}
367 else {setverdict(fail);}
368 }
369
370 testcase templateCharstrRange3() runs on templateCharstr_mycomp {
371 var templateCharstr_rec x1,x2,x3; //Range, with infinity
372 x1:={ x1:="1", x2:="8", x3:="3" };
373 x2:={ x1:="1", x2:="2", x3:="3" };
374 x3:={ x1:="2", x2:="2", x3:="3" };
375 //match
376 if (match(x1,templateCharstr_tRange3)) {setverdict(pass);}
377 else {setverdict(fail);}
378 //no match: out of range
379 if (not(match(x2,templateCharstr_tRange3))) {setverdict(pass);}
380 else {setverdict(fail);}
381 //no match: other field
382 if (not(match(x3,templateCharstr_tRange3))) {setverdict(pass);}
383 else {setverdict(fail);}
384 }
385
386 testcase templateCharstrRange4() runs on templateCharstr_mycomp {
387 var templateCharstr_rec x1,x2,x3; //Range with - infinity
388 x1:={ x1:="1", x2:="2", x3:="3" };
389 x2:={ x1:="1", x2:="5", x3:="3" };
390 x3:={ x1:="2", x2:="2", x3:="3" };
391 //match
392 if (match(x1,templateCharstr_tRange4)) {setverdict(pass);}
393 else {setverdict(fail);}
394 //no match: out of range
395 if (not(match(x2,templateCharstr_tRange4))) {setverdict(pass);}
396 else {setverdict(fail);}
397 //no match: other field
398 if (not(match(x3,templateCharstr_tRange4))) {setverdict(pass);}
399 else {setverdict(fail);}
400 }
401
402
403 type record templateCharstr_myrec {
404 charstring f1 optional,
405 charstring f2 optional
406 }
407
408 const templateCharstr_myrec mr := {
409 f1 := "b",
410 f2 := "a"
411 }
412
413 type component templateCharstr_mycomp2 {
414 const charstring x1 := "";
415 var charstring x2 := "";
416 const charstring x3 := "x";
417 var charstring x4 := "x";
418 }
419
420 function tryPatternReferenceWithOptionalField(in templateCharstr_myrec p) runs on templateCharstr_mycomp2
421 { // regression test for TR 909
422 template charstring piecemeal := pattern "{p.f1}{p.f2}r";
423 if (match("bar", piecemeal)) { setverdict(pass); }
424 else { setverdict(fail); }
425 if (match("r", piecemeal)) { setverdict(fail); }
426 else { setverdict(pass); }
427
428 var template charstring piecemealv := pattern "{p.f1}{p.f2}r";
429 if (match("bar", piecemealv)) { setverdict(pass); }
430 else { setverdict(fail); }
431 if (match("r", piecemealv)) { setverdict(fail); }
432 else { setverdict(pass); }
433 }
434
435 testcase templateCharstrEmptyPattern() runs on templateCharstr_mycomp2
436 {
437 if (match("", pattern "")) { setverdict(pass); }
438 else { setverdict(fail); }
439 if (not match("x", pattern "{x1}{x2}")) { setverdict(pass); }
440 else { setverdict(fail); }
441 if (match("xxx", pattern "{x3}x{x4}")) { setverdict(pass); }
442 else { setverdict(fail); }
443
444 tryPatternReferenceWithOptionalField(mr);
445 }
446
447 testcase templateCharstrRepeat() runs on templateCharstr_mycomp {
448 var templateCharstr_rec x1,x2,x3,x4; //repeat
449 x1:={ x1:="666", x2:="", x3:="666" };
450 x2:={ x1:="6" , x2:="", x3:="666" };
451 x3:={ x1:="666", x2:="", x3:="6666" };
452 x4:={ x1:="666", x2:="6 6 6", x3:="666" };
453 //match
454 if (match(x1,templateCharstr_tRepeat)) {setverdict(pass);}
455 else {setverdict(fail);}
456 //no match
457 if (not(match(x2,templateCharstr_tRepeat))) {setverdict(pass);}
458 else {setverdict(fail);}
459 if (not(match(x3,templateCharstr_tRepeat))) {setverdict(pass);}
460 else {setverdict(fail);}
461 if (not(match(x4,templateCharstr_tRepeat))) {setverdict(pass);}
462 else {setverdict(fail);}
463 }
464
465 testcase templateCharstrRepeatFull() runs on templateCharstr_mycomp {
466 var templateCharstr_rec x0,x1,x2,x3,x4; //repeat
467 x0:={ x1:="666", x2:="", x3:="666" }; // shortest possible
468 x1:={ x1:="6666", x2:="666", x3:="666" }; // just over
469 x2:={ x1:="6" , x2:="", x3:="666" }; // fail first
470 x3:={ x1:="666", x2:="6666", x3:="6666" }; // fail second
471 x4:={ x1:="666", x2:="", x3:="6" }; // fail third
472 //match
473 if (match(x0,templateCharstr_tRepeatFull)) {setverdict(pass);}
474 else {setverdict(fail);}
475 if (match(x1,templateCharstr_tRepeatFull)) {setverdict(pass);}
476 else {setverdict(fail);}
477 //no match
478 if (not(match(x2,templateCharstr_tRepeatFull))) {setverdict(pass);}
479 else {setverdict(fail);}
480 if (not(match(x3,templateCharstr_tRepeatFull))) {setverdict(pass);}
481 else {setverdict(fail);}
482 if (not(match(x4,templateCharstr_tRepeatFull))) {setverdict(pass);}
483 else {setverdict(fail);}
484 }
485
486 testcase templateCharstrPattern() runs on templateCharstr_mycomp {
487 var templateCharstr_rec x0, x1, x2, x3, x4; // pattern
488 x0 := { x1 := "abc,xyz", x2 := "abc1xyz", x3 := "abcxyz" };
489 x1 := { x1 := "abcpxyz", x2 := "abcPxyz", x3 := "abc123abcJKL.? \txyz" };
490 x2 := { x1 := "abcxyz", x2 := "abcPxyz", x3 := "abc123xyz" }; // fail first
491 x3 := { x1 := "abcpxyz", x2 := "abc123xyz", x3 := "abc123xyz" }; // fail second
492 x4 := { x1 := "abcpxyz", x2 := "abcPxyz", x3 := "abc123xy z" }; // fail third
493
494 // match
495 if (match(x0, templateCharstr_tPattern)) { setverdict(pass); }
496 else { setverdict(fail); }
497 if (match(x1, templateCharstr_tPattern)) { setverdict(pass); }
498 else { setverdict(fail); }
499
500 // not match
501 if (not match(x2, templateCharstr_tPattern)) { setverdict(pass); }
502 else { setverdict(fail); }
503 if (not match(x3, templateCharstr_tPattern)) { setverdict(pass); }
504 else { setverdict(fail); }
505 if (not match(x4, templateCharstr_tPattern)) { setverdict(pass); }
506 else { setverdict(fail); }
507 }
508
509 testcase TR920() runs on templateCharstr_mycomp {
510 var template charstring temp := pattern "[0-9]|[0-9][0-9]";
511 const charstring x := "10a";
512
513 if(match(x, temp)){
514 setverdict(fail);
515 }else{
516 setverdict(pass);
517 }
518 }
519
520 // http://t-ort.etsi.org/view.php?id=3761
521 testcase templateCharstrPatternCat() runs on templateCharstr_mycomp
522 {
523 if (match("aazz", pattern "a" & "*z")) { setverdict(pass); }
524 else { setverdict(fail); }
525 if (match("AAZZ", pattern "a*" & "z|" & "A*Z")) { setverdict(pass); }
526 else { setverdict(fail); }
527 if (match("AAZZ0123456789", pattern "(a*" & "z|" & "A*Z)" & "[0-9]+")) { setverdict(pass); }
528 else { setverdict(fail); }
529 }
530
531 testcase CatBasic() runs on templateCharstr_mycomp {
532 var charstring cs1 := "xyz"
533 var charstring cs2 := "(xyz)*[abc]+"
534 var charstring cs3 := "{xyz}" // No run-time references.
535 var template charstring t1, t2, t3, t4, t5, t6, t7
536 t1 := pattern cs1
537 t2 := pattern cs2
538 t3 := pattern cs1 & "utoljara"
539 t4 := pattern cs1 & "utoljar(a)+" & cs1
540 t5 := pattern "utoljara" & cs1
541 t6 := pattern "valami" & cs1 & "megegyszer" & "utoljara"
542 t7 := pattern "valami" & cs3 & "megegyszer" & "utoljara"
543 if (match("xyz", t1)) { setverdict(pass) } else { setverdict(fail) }
544 if (match("xyzxyzxyza", t2)) { setverdict(pass) } else { setverdict(fail) }
545 if (match("xyzabcaabbccac", t2)) { setverdict(pass) } else { setverdict(fail) }
546 if (match("xyzutoljara", t3)) { setverdict(pass) } else { setverdict(fail) }
547 if (match("xyzutoljaraaaaaaaaaaaxyz", t4)) { setverdict(pass) } else { setverdict(fail) }
548 if (match("utoljaraxyz", t5)) { setverdict(pass) } else { setverdict(fail) }
549 if (match("valamixyzmegegyszerutoljara", t6)) { setverdict(pass) } else { setverdict(fail) }
550 if (match("valami{xyz}megegyszerutoljara", t7)) { setverdict(pass) } else { setverdict(fail) }
551 }
552
553 template srec pt1(in charstring sp) := { s := pattern sp }
554 template srec pt2(in charstring sp) := { s := pattern sp & "megvalami" }
555 template srec pt3(in charstring sp) := { s := pattern "valami" & sp }
556 template srec pt4(in charstring sp) := { s := pattern "valami" & sp & "megvalami" }
557 template srec pt5(in charstring sp) := { s := pattern sp & "valami" & sp }
558
559 testcase CatParametrized() runs on templateCharstr_mycomp
560 {
561 var srec r1, r2, r3, r4, r5
562 r1 := { "xyz" }
563 r2 := { "xyzmegvalami" }
564 r3 := { "valamixyz" }
565 r4 := { "valamixyzmegvalami" }
566 r5 := { "xyzvalamixyz" }
567 if (match(r1, pt1("xyz"))) { setverdict(pass) } else { setverdict(fail) }
568 if (match(r2, pt2("xyz"))) { setverdict(pass) } else { setverdict(fail) }
569 if (match(r3, pt3("xyz"))) { setverdict(pass) } else { setverdict(fail) }
570 if (match(r4, pt4("xyz"))) { setverdict(pass) } else { setverdict(fail) }
571 if (match(r5, pt5("xyz"))) { setverdict(pass) } else { setverdict(fail) }
572 }
573
574 function f1(in charstring s) return integer {
575 var template charstring t := pattern s; if (match(s, t)) { return 0 } else { return 1 }
576 }
577
578 function f2(in charstring s) return integer {
579 var template charstring t := pattern s & "megvalami"; if (match(s & "megvalami", t)) { return 0 } else { return 1 }
580 }
581
582 function f3(in charstring s) return integer {
583 var template charstring t := pattern "valami" & s; if (match("valami" & s, t)) { return 0 } else { return 1 }
584 }
585
586 function f4(in charstring s) return integer {
587 var template charstring t := pattern "valami" & s & "megvalami"; if (match("valami" & s & "megvalami", t)) { return 0 } else { return 1 }
588 }
589
590 function f5(in charstring s) return integer {
591 var template charstring t := pattern s & "valami" & s; if (match(s & "valami" & s, t)) { return 0 } else { return 1 }
592 }
593
594 type record srec { charstring s }
595
596 testcase CatFunctions() runs on templateCharstr_mycomp
597 {
598 if (f1("xyz") == 0) { setverdict(pass) } else { setverdict(fail) }
599 if (f2("xyz") == 0) { setverdict(pass) } else { setverdict(fail) }
600 if (f3("xyz") == 0) { setverdict(pass) } else { setverdict(fail) }
601 if (f4("xyz") == 0) { setverdict(pass) } else { setverdict(fail) }
602 if (f5("xyz") == 0) { setverdict(pass) } else { setverdict(fail) }
603 }
604
605 testcase CatStructured() runs on templateCharstr_mycomp
606 {
607 var srec r1 := { "xyz" }
608 var template charstring t1, t2, t3, t4, t5
609 t1 := pattern r1.s
610 t2 := pattern r1.s & "megvalami"
611 t3 := pattern "valami" & r1.s
612 t4 := pattern "valami" & r1.s & "megvalami"
613 t5 := pattern r1.s & "valami" & r1.s
614 if (match("xyz", t1)) { setverdict(pass) } else { setverdict(fail) }
615 if (match("xyzmegvalami", t2)) { setverdict(pass) } else { setverdict(fail) }
616 if (match("valamixyz", t3)) { setverdict(pass) } else { setverdict(fail) }
617 if (match("valamixyzmegvalami", t4)) { setverdict(pass) } else { setverdict(fail) }
618 if (match("xyzvalamixyz", t5)) { setverdict(pass) } else { setverdict(fail) }
619 }
620
621
622 const charstring base_1:= "ab?";
623 const charstring base_2 := "ab*";
624
625 template charstring p1:= pattern "{base_1}";
626 template charstring p2:= pattern base_1;
627
628 template charstring p3 := pattern "{base_2}";
629 template charstring p4 := pattern base_2;
630
631 template charstring p5 := pattern "{p3}{p3}";
632 template charstring p6 := pattern "{p3}" & "{p3}";
633 template charstring p7 := pattern p3 & p3;
634 template charstring p8 := pattern "c{p4}d";
635
636
637 testcase pattern_reference() runs on templateCharstr_mycomp {
638
639 var charstring string_1 := "abc";
640 var charstring string_2 := "ab"
641
642 if (match(string_1, p1)) {setverdict(pass);} else {setverdict(fail);}
643 if (match(base_1, p1)) {setverdict(pass);} else {setverdict(fail);}
644 if (match(base_1, p2)) {setverdict(pass);} else {setverdict(fail);}
645
646 if (match(string_2, p3)) {setverdict(pass);} else {setverdict(fail);}
647 if (match(base_2, p3)) {setverdict(pass);} else {setverdict(fail);}
648 if (match(base_2, p4)) {setverdict(pass);} else {setverdict(fail);}
649
650 if (match("abnabn", p5)) {setverdict(pass);} else {setverdict(fail);}
651 if (match("abnabn", p6)) {setverdict(pass);} else {setverdict(fail);}
652 if (match("abnabn", p7)) {setverdict(pass);} else {setverdict(fail);}
653 if (match("cabxd", p8)) {setverdict(pass);} else {setverdict(fail);}
654
655 }
656
657 type record of charstring Ss;
658
659 type record ss_x
660 {
661 //integer a;
662 charstring a,
663 integer b
664 };
665
666
667 type record ss_x2
668 {
669 //integer a;
670 ss_x a,
671 integer b
672 };
673
674
675 testcase HO30913_reference() runs on templateCharstr_mycomp {
676 //test to check [1] reference
677
678 var Ss ss;
679 var charstring s;
680
681 s := "s";
682 ss[0] := "0";
683 ss[1] := "1";
684 log(match(ss[0], pattern s)); // this compiles
685 log(match(ss[0], pattern ss[1])); // this does not compile
686
687 var ss_x xx;
688 var ss_x2 xx2;
689
690 xx.a := "a";
691
692 //log(match(ss[0], pattern x.a)); // this does not compile segmentation fault
693 log(match(ss[0], pattern xx.a )); // this does not compile
694 setverdict(pass);
695 }
696
697 testcase CR_TR00018474() runs on templateCharstr_mycomp {
698 // Indexing of string template variables.
699 var template charstring vtc1 := "fisherman"
700 var template charstring vtc2 := "?*?****" // It's still a plain charstring.
701 vtc1[0] := "F" // Normal usage.
702 if (match("Fisherman", vtc1)) { setverdict(pass) } else { setverdict(fail) }
703 vtc1[0] := "*" // Just an ASCII character.
704 if (match("*isherman", vtc1)) { setverdict(pass) } else { setverdict(fail) }
705 vtc1[1] := "?" // Just an ASCII character.
706 if (match("*?sherman", vtc1)) { setverdict(pass) } else { setverdict(fail) }
707 vtc1[0] := "F" // Indexed assignment notation cannot be used here.
708 vtc1[1] := "i" // Still works, nothing special.
709 if (match("Fisherman", vtc1)) { setverdict(pass) } else { setverdict(fail) }
710 vtc2[0] := "*"
711 if (match("**?****", vtc2)) { setverdict(pass) } else { setverdict(fail) }
712 }
713
714 control {
715 execute(templateCharstrSpec());
716 execute(templateCharstrList());
717 execute(templateCharstrComp());
718 execute(templateCharstrOmit());
719 execute(templateCharstrAny());
720 execute(templateCharstrAnyorNone());
721 execute(templateCharstrLength1());
722 execute(templateCharstrLength2());
723 execute(templateCharstrLength3());
724 execute(templateCharstrIfpresent());
725 execute(templateCharstrLengthIfp());
726 execute(templateCharstrAnyEl());
727 execute(templateCharstrAnyorNoneEl());
728 execute(templateCharstrRange1());
729 execute(templateCharstrRange2());
730 execute(templateCharstrRange3());
731 execute(templateCharstrRange4());
732 execute(templateCharstrEmptyPattern());
733 execute(templateCharstrRepeat());
734 execute(templateCharstrRepeatFull());
735 execute(templateCharstrPattern());
736 execute(TR920());
737 execute(templateCharstrPatternCat());
738 execute(CatBasic())
739 execute(CatParametrized())
740 execute(CatFunctions())
741 execute(CatStructured())
742 execute(pattern_reference());
743 execute(HO30913_reference());
744 execute(CR_TR00018474());
745 }
746 }
This page took 0.045943 seconds and 5 git commands to generate.