handle environmental variables when we create folders dynamically to
[deliverable/titan.core.git] / regression_test / templateCharstr / TtemplateCharstr.ttcn
CommitLineData
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 * Baranyi, Botond
11 * Godar, Marton
12 * Kovacs, Ferenc
13 * Raduly, Csaba
14 * Szabados, Kristof
15 * Szabo, Janos Zoltan – initial implementation
16 * Pandi, Krisztian
17 *
970ed795
EL
18 ******************************************************************************/
19module TtemplateCharstr {
20type component templateCharstr_mycomp {};
21type record templateCharstr_rec {
22 charstring x1,
23 charstring x2,
24 charstring x3 optional };
25template templateCharstr_rec templateCharstr_tSpec :={ //specific values
26 x1:="00AA",
27 x2:="01AA",
28 x3:="10AA" };
29template templateCharstr_rec templateCharstr_tList :={ //specific value and value list
30 x1:="00AA",
31 x2:=("01AA","01AB","11AC"),
32 x3:="10AA" };
33template templateCharstr_rec templateCharstr_tComp :={ //specific value and compl. list
34 x1:="00AA",
35 x2:=complement ("11","0A","1BC0"),
36 x3:="10AA" };
37template templateCharstr_rec templateCharstr_tOmit :={ //omitting values
38 x1:="00AA",
39 x2:="01AA",
40 x3:=omit } ;
41template templateCharstr_rec templateCharstr_tAny :={ //specific and any value
42 x1:="00AA",
43 x2:="01AA",
44 x3:=? } ;
45template templateCharstr_rec templateCharstr_tAnyorNone :={ //specific and AnyorNone value
46 x1:="00AA",
47 x2:="01AA",
48 x3:=* };
49template templateCharstr_rec templateCharstr_tLength1 :={ //specific value and fix length
50 x1:="00AA",
51 x2:="01AA",
52 x3:=* length(3) };
53template templateCharstr_rec templateCharstr_tLength2 :={ //specific value and length (range)
54 x1:="00AA",
55 x2:="01AA",
56 x3:=? length(2..4) };
57template templateCharstr_rec templateCharstr_tLength3 :={ //specific value and length (range, infinity)
58 x1:="00AA",
59 x2:="01AA",
60 x3:=? length(2..infinity) };
61template 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};
69template templateCharstr_rec templateCharstr_tAnyEl :={ //specific value and any element inside value
70 x1:="00AA",
71 x2:="01AA",
72 x3:= pattern "10?" } ;
73template 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*" };
77template templateCharstr_rec templateCharstr_tRange1 :={ //specific value and Range
78 x1:="1",
79 x2:=("2" .."4"),
80 x3:="3" };
81template templateCharstr_rec templateCharstr_tRange2 :={ //specific value and Range
82 x1:="1",
83 x2:=("2" .. "4"),
84 x3:="3" };
85template templateCharstr_rec templateCharstr_tRange3 :={ //specific value and Range
86 x1:="1",
87 x2:=("3" .. int2char(127)),
88 x3:="3" };
89template templateCharstr_rec templateCharstr_tRange4 :={ //specific value and Range
90 x1:="1",
91 x2:=(int2char(0) .. "4"),
92 x3:="3" };
93template templateCharstr_rec templateCharstr_tRepeat := {
94 x1:= pattern "6#3", // precisely 3
95 x2:= pattern "6#(,)", // any number
96 x3:= pattern "6#(3)" }; // precisely 3
97template 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
feade998 101template templateCharstr_rec templateCharstr_tPattern := {
102 x1 := pattern "abc?xyz",
103 x2 := pattern @nocase "abc?xyz",
104 x3 := pattern @nocase "abc*xyz" };
970ed795
EL
105
106testcase templateCharstrSpec() runs on templateCharstr_mycomp {
107var templateCharstr_rec x1,x2; //specific value
108x1:={ x1:="00AA", x2:="01AA", x3:="10AA" };
109x2:={ x1:="00BC", x2:="01AA", x3:="10AA" };
110//match
111if (match(x1,templateCharstr_tSpec)) {setverdict(pass);}
112 else {setverdict(fail);}
113//no match
114if (not(match(x2,templateCharstr_tSpec))) {setverdict(pass);}
115 else {setverdict(fail);}
116}
117
118testcase templateCharstrList() runs on templateCharstr_mycomp {
119var templateCharstr_rec x1,x2,x3; //value list
120x1:={ x1:="00AA", x2:="01AA", x3:="10AA" };
121x2:={ x1:="00AA", x2:="00", x3:="10AA" };
122x3:={ x1:="1D", x2:="01AA", x3:="10AA" };
123//match
124if (match(x1,templateCharstr_tList)) {setverdict(pass);}
125 else {setverdict(fail);}
126//no match: out of list
127if (not(match(x2,templateCharstr_tList))) {setverdict(pass);}
128 else {setverdict(fail);}
129//no match: other field
130if (not(match(x3,templateCharstr_tList))) {setverdict(pass);}
131 else {setverdict(fail);}
132}
133
134testcase templateCharstrComp() runs on templateCharstr_mycomp {
135var templateCharstr_rec x1,x2,x3; //complemented list
136x1:={ x1:="00AA", x2:="01AA", x3:="10AA" };
137x2:={ x1:="00AA", x2:="0A", x3:="10AA" };
138x3:={ x1:="11AA", x2:="01AA", x3:="10AA" };
139//match
140if (match(x1,templateCharstr_tComp)) {setverdict(pass);}
141 else {setverdict(fail);}
142//no match: in the list
143if (not(match(x2,templateCharstr_tComp))) {setverdict(pass);}
144 else {setverdict(fail);}
145//no match: other field
146if (not(match(x3,templateCharstr_tComp))) {setverdict(pass);}
147 else {setverdict(fail);}
148}
149
150testcase templateCharstrOmit() runs on templateCharstr_mycomp {
151var templateCharstr_rec x1,x2,x3; //omitting value
152x1:={ x1:="00AA", x2:="01AA", x3:=omit };
153x2:={ x1:="00AA", x2:="01AA", x3:="AB" };
154x3:={ x1:="00DE", x2:="01AA", x3:=omit };
155//match
156if (match(x1,templateCharstr_tOmit)) {setverdict(pass);}
157 else {setverdict(fail);}
158//no match: not omitted
159if (not(match(x2,templateCharstr_tOmit))) {setverdict(pass);}
160 else {setverdict(fail);}
161//no match: other field
162if (not(match(x3,templateCharstr_tOmit))) {setverdict(pass);}
163 else {setverdict(fail);}
164}
165
166testcase templateCharstrAny() runs on templateCharstr_mycomp {
167var templateCharstr_rec x1,x2,x3; //any value
168x1:={ x1:="00AA", x2:="01AA", x3:="ABCD" };
169x2:={ x1:="00AA", x2:="01AA", x3:=omit };
170x3:={ x1:="0A", x2:="01AA", x3:="ABCD" };
171//match
172if (match(x1,templateCharstr_tAny)) {setverdict(pass);}
173 else {setverdict(fail);}
174//no match: field omitted
175if (not(match(x2,templateCharstr_tAny))) {setverdict(pass);}
176 else {setverdict(fail);}
177//no match: other field
178if (not(match(x3,templateCharstr_tAny))) {setverdict(pass);}
179 else {setverdict(fail);}
180}
181
182testcase templateCharstrAnyorNone() runs on templateCharstr_mycomp {
183var templateCharstr_rec x1,x2,x3; //AnyorNone value
184x1:={ x1:="00AA", x2:="01AA", x3:=omit };
185x2:={ x1:="00AA", x2:="01AA", x3:="10AB" };
186x3:={ x1:="1C", x2:="01AA", x3:=omit };
187//match: omitted
188if (match(x1,templateCharstr_tAnyorNone)) {setverdict(pass);}
189 else {setverdict(fail);}
190//match: value
191if (match(x2,templateCharstr_tAnyorNone)) {setverdict(pass);}
192 else {setverdict(fail);}
193//no match: other field
194if (not(match(x3,templateCharstr_tAnyorNone))) {setverdict(pass);}
195 else {setverdict(fail);}
196}
197
198testcase templateCharstrLength1() runs on templateCharstr_mycomp {
199var templateCharstr_rec x1,x2,x3,x4; //length (fix)
200x1:={ x1:="00AA", x2:="01AA", x3:="abc" };
201x2:={ x1:="00AA", x2:="01AA", x3:="abc" };
202x3:={ x1:="00AA", x2:="01AA", x3:="1D" };
203x4:={ x1:="001A", x2:="01AA", x3:="abc" };
204//match: proper length
205if (match(x1,templateCharstr_tLength1)) {setverdict(pass);}
206 else {setverdict(fail);}
207//match: omitted
208if (match(x2,templateCharstr_tLength1)) {setverdict(pass);}
209 else {setverdict(fail);}
210// no match: not proper length
211if (not(match(x3,templateCharstr_tLength1))) {setverdict(pass);}
212 else {setverdict(fail);}
213//no match: other field
214if (not(match(x4,templateCharstr_tLength1))) {setverdict(pass);}
215 else {setverdict(fail);}
216}
217
218testcase templateCharstrLength2() runs on templateCharstr_mycomp {
219var templateCharstr_rec x1,x2,x3; //length (range)
220x1:={ x1:="00AA", x2:="01AA", x3:="abcd" };
221x2:={ x1:="00AA", x2:="01AA", x3:="a" };
222x3:={ x1:="001A", x2:="01AA", x3:="abc" };
223//match
224if (match(x1,templateCharstr_tLength2)) {setverdict(pass);}
225 else {setverdict(fail);}
226// no match: not proper length
227if (not(match(x2,templateCharstr_tLength2))) {setverdict(pass);}
228 else {setverdict(fail);}
229//no match: other field
230if (not(match(x3,templateCharstr_tLength2))) {setverdict(pass);}
231 else {setverdict(fail);}
232}
233
234testcase templateCharstrLength3() runs on templateCharstr_mycomp {
235var templateCharstr_rec x1,x2,x3; //length (range, infinity)
236x1:={ x1:="00AA", x2:="01AA", x3:="abcd" };
237x2:={ x1:="00AA", x2:="01AA", x3:="a" };
238x3:={ x1:="001A", x2:="01AA", x3:="abc" };
239//match
240if (match(x1,templateCharstr_tLength3)) {setverdict(pass);}
241 else {setverdict(fail);}
242// no match: not proper length
243if (not(match(x2,templateCharstr_tLength3))) {setverdict(pass);}
244 else {setverdict(fail);}
245//no match: other field
246if (not(match(x3,templateCharstr_tLength3))) {setverdict(pass);}
247 else {setverdict(fail);}
248}
249testcase templateCharstrIfpresent() runs on templateCharstr_mycomp {
250var templateCharstr_rec x1,x2,x3,x4; //ifpresent
251x1:={ x1:="00AA", x2:="01AA", x3:="10AA" };
252x2:={ x1:="00AA", x2:="01AA", x3:=omit };
253x3:={ x1:="00AA", x2:="01AA", x3:="00AA" };
254x4:={ x1:="00", x2:="01AA", x3:=omit };
255//match: present and match
256if (match(x1,templateCharstr_tIfpresent)) {setverdict(pass);}
257 else {setverdict(fail);}
258//match: not present
259if (match(x2,templateCharstr_tIfpresent)) {setverdict(pass);}
260 else {setverdict(fail);}
261//no match: present and not match
262if (not(match(x3,templateCharstr_tIfpresent))) {setverdict(pass);}
263 else {setverdict(fail);}
264//no match: other field
265if (not(match(x4,templateCharstr_tIfpresent))) {setverdict(pass);}
266 else {setverdict(fail);}
267}
268
269testcase templateCharstrLengthIfp() runs on templateCharstr_mycomp {
270var templateCharstr_rec x1,x2,x3,x4; //length (fix), ifpresent
271x1:={ x1:="00AA", x2:="01AA", x3:="abc" };
272x2:={ x1:="00AA", x2:="01AA", x3:="abc" };
273x3:={ x1:="00AA", x2:="01AA", x3:="1D" };
274x4:={ x1:="001A", x2:="01AA", x3:="abc" };
275//match: proper length
276if (match(x1,templateCharstr_tLengthIfp)) {setverdict(pass);}
277 else {setverdict(fail);}
278//match: omitted
279if (match(x2,templateCharstr_tLengthIfp)) {setverdict(pass);}
280 else {setverdict(fail);}
281// no match: not proper length
282if (not(match(x3,templateCharstr_tLengthIfp))) {setverdict(pass);}
283 else {setverdict(fail);}
284//no match: other field
285if (not(match(x4,templateCharstr_tLengthIfp))) {setverdict(pass);}
286 else {setverdict(fail);}
287}
288
289testcase templateCharstrAnyEl() runs on templateCharstr_mycomp {
290var templateCharstr_rec x1,x2,x3,x4,x5; //any element
291x1:={ x1:="00AA", x2:="01AA", x3:="10a" };
292x2:={ x1:="00AA", x2:="01AA", x3:="10" };
293x3:={ x1:="00AA", x2:="01AA", x3:="10Aa" };
294x4:={ x1:="00AA", x2:="01AA", x3:="12A" };
295x5:={ x1:="0A", x2:="01AA", x3:="10a" };
296//match
297if (match(x1,templateCharstr_tAnyEl)) {setverdict(pass);}
298 else {setverdict(fail);}
299//no match: no element
300if (not(match(x2,templateCharstr_tAnyEl))) {setverdict(pass);}
301 else {setverdict(fail);}
302//no match: two element
303if (not(match(x3,templateCharstr_tAnyEl))) {setverdict(pass);}
304 else {setverdict(fail);}
305//no match: wrong element
306if (not(match(x4,templateCharstr_tAnyEl))) {setverdict(pass);}
307 else {setverdict(fail);}
308//no match: other field
309if (not(match(x5,templateCharstr_tAnyEl))) {setverdict(pass);}
310 else {setverdict(fail);}
311}
312
313testcase templateCharstrAnyorNoneEl() runs on templateCharstr_mycomp {
314var templateCharstr_rec x1,x2,x3,x4,x5; //Any number of elements or none
315x1:={ x1:="00AA", x2:="01AA", x3:="10" };
316x2:={ x1:="00AA", x2:="01AA", x3:="10k" };
317x3:={ x1:="00AA", x2:="01AA", x3:="10Aa" };
318x4:={ x1:="00AA", x2:="01AA", x3:="11a" };
319x5:={ x1:="1A", x2:="01AA", x3:="10a" };
320//match: no element
321if (match(x1,templateCharstr_tAnyorNoneEl)) {setverdict(pass);}
322 else {setverdict(fail);}
323//match: one element
324if (match(x2,templateCharstr_tAnyorNoneEl)) {setverdict(pass);}
325 else {setverdict(fail);}
326//match: two element
327if (match(x3,templateCharstr_tAnyorNoneEl)) {setverdict(pass);}
328 else {setverdict(fail);}
329//no match: wrong element
330if (not(match(x4,templateCharstr_tAnyorNoneEl))) {setverdict(pass);}
331 else {setverdict(fail);}
332//no match: other field
333if (not(match(x5,templateCharstr_tAnyorNoneEl))) {setverdict(pass);}
334 else {setverdict(fail);}
335}
336
337
338testcase templateCharstrRange1() runs on templateCharstr_mycomp {
339var templateCharstr_rec x1,x2,x3; //Range ( .. )
340x1:={ x1:="1", x2:="2", x3:="3" };
341x2:={ x1:="1", x2:="5", x3:="3" };
342x3:={ x1:="2", x2:="2", x3:="3" };
343//match
344if (match(x1,templateCharstr_tRange1)) {setverdict(pass);}
345 else {setverdict(fail);}
346//no match: out of range
347if (not(match(x2,templateCharstr_tRange1))) {setverdict(pass);}
348 else {setverdict(fail);}
349//no match: other field
350if (not(match(x3,templateCharstr_tRange1))) {setverdict(pass);}
351 else {setverdict(fail);}
352}
353
354testcase templateCharstrRange2() runs on templateCharstr_mycomp {
355var templateCharstr_rec x1,x2,x3; //Range ( to )
356x1:={ x1:="1", x2:="2", x3:="3" };
357x2:={ x1:="1", x2:="5", x3:="3"};
358x3:={ x1:="2", x2:="2", x3:="3" };
359//match
360if (match(x1,templateCharstr_tRange2)) {setverdict(pass);}
361 else {setverdict(fail);}
362//no match: out of range
363if (not(match(x2,templateCharstr_tRange2))) {setverdict(pass);}
364 else {setverdict(fail);}
365//no match: other field
366if (not(match(x3,templateCharstr_tRange2))) {setverdict(pass);}
367 else {setverdict(fail);}
368}
369
370testcase templateCharstrRange3() runs on templateCharstr_mycomp {
371var templateCharstr_rec x1,x2,x3; //Range, with infinity
372x1:={ x1:="1", x2:="8", x3:="3" };
373x2:={ x1:="1", x2:="2", x3:="3" };
374x3:={ x1:="2", x2:="2", x3:="3" };
375//match
376if (match(x1,templateCharstr_tRange3)) {setverdict(pass);}
377 else {setverdict(fail);}
378//no match: out of range
379if (not(match(x2,templateCharstr_tRange3))) {setverdict(pass);}
380 else {setverdict(fail);}
381//no match: other field
382if (not(match(x3,templateCharstr_tRange3))) {setverdict(pass);}
383 else {setverdict(fail);}
384}
385
386testcase templateCharstrRange4() runs on templateCharstr_mycomp {
387var templateCharstr_rec x1,x2,x3; //Range with - infinity
388x1:={ x1:="1", x2:="2", x3:="3" };
389x2:={ x1:="1", x2:="5", x3:="3" };
390x3:={ x1:="2", x2:="2", x3:="3" };
391//match
392if (match(x1,templateCharstr_tRange4)) {setverdict(pass);}
393 else {setverdict(fail);}
394//no match: out of range
395if (not(match(x2,templateCharstr_tRange4))) {setverdict(pass);}
396 else {setverdict(fail);}
397//no match: other field
398if (not(match(x3,templateCharstr_tRange4))) {setverdict(pass);}
399 else {setverdict(fail);}
400}
401
402
403type record templateCharstr_myrec {
404 charstring f1 optional,
405 charstring f2 optional
406}
407
408const templateCharstr_myrec mr := {
409 f1 := "b",
410 f2 := "a"
411}
412
413type component templateCharstr_mycomp2 {
414 const charstring x1 := "";
415 var charstring x2 := "";
416 const charstring x3 := "x";
417 var charstring x4 := "x";
418}
419
420function 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
435testcase 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
447testcase templateCharstrRepeat() runs on templateCharstr_mycomp {
448var templateCharstr_rec x1,x2,x3,x4; //repeat
449x1:={ x1:="666", x2:="", x3:="666" };
450x2:={ x1:="6" , x2:="", x3:="666" };
451x3:={ x1:="666", x2:="", x3:="6666" };
452x4:={ x1:="666", x2:="6 6 6", x3:="666" };
453//match
454if (match(x1,templateCharstr_tRepeat)) {setverdict(pass);}
455 else {setverdict(fail);}
456//no match
457if (not(match(x2,templateCharstr_tRepeat))) {setverdict(pass);}
458 else {setverdict(fail);}
459if (not(match(x3,templateCharstr_tRepeat))) {setverdict(pass);}
460 else {setverdict(fail);}
461if (not(match(x4,templateCharstr_tRepeat))) {setverdict(pass);}
462 else {setverdict(fail);}
463}
464
465testcase templateCharstrRepeatFull() runs on templateCharstr_mycomp {
466var templateCharstr_rec x0,x1,x2,x3,x4; //repeat
467x0:={ x1:="666", x2:="", x3:="666" }; // shortest possible
468x1:={ x1:="6666", x2:="666", x3:="666" }; // just over
469x2:={ x1:="6" , x2:="", x3:="666" }; // fail first
470x3:={ x1:="666", x2:="6666", x3:="6666" }; // fail second
471x4:={ x1:="666", x2:="", x3:="6" }; // fail third
472//match
473if (match(x0,templateCharstr_tRepeatFull)) {setverdict(pass);}
474 else {setverdict(fail);}
475if (match(x1,templateCharstr_tRepeatFull)) {setverdict(pass);}
476 else {setverdict(fail);}
477//no match
478if (not(match(x2,templateCharstr_tRepeatFull))) {setverdict(pass);}
479 else {setverdict(fail);}
480if (not(match(x3,templateCharstr_tRepeatFull))) {setverdict(pass);}
481 else {setverdict(fail);}
482if (not(match(x4,templateCharstr_tRepeatFull))) {setverdict(pass);}
483 else {setverdict(fail);}
484}
485
feade998 486testcase 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
970ed795
EL
509testcase 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
521testcase 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
531testcase 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
553template srec pt1(in charstring sp) := { s := pattern sp }
554template srec pt2(in charstring sp) := { s := pattern sp & "megvalami" }
555template srec pt3(in charstring sp) := { s := pattern "valami" & sp }
556template srec pt4(in charstring sp) := { s := pattern "valami" & sp & "megvalami" }
557template srec pt5(in charstring sp) := { s := pattern sp & "valami" & sp }
558
559testcase 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
574function f1(in charstring s) return integer {
575 var template charstring t := pattern s; if (match(s, t)) { return 0 } else { return 1 }
576}
577
578function 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
582function 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
586function 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
590function 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
594type record srec { charstring s }
595
596testcase 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
605testcase 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
622const charstring base_1:= "ab?";
623const charstring base_2 := "ab*";
624
625template charstring p1:= pattern "{base_1}";
626template charstring p2:= pattern base_1;
627
628template charstring p3 := pattern "{base_2}";
629template charstring p4 := pattern base_2;
630
631template charstring p5 := pattern "{p3}{p3}";
632template charstring p6 := pattern "{p3}" & "{p3}";
633template charstring p7 := pattern p3 & p3;
634template charstring p8 := pattern "c{p4}d";
635
636
637testcase 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
657type record of charstring Ss;
658
659type record ss_x
660{
661 //integer a;
662 charstring a,
663 integer b
664};
665
666
667type record ss_x2
668{
669 //integer a;
670 ss_x a,
671 integer b
672};
673
674
675testcase 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
697testcase 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
714control {
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());
feade998 735 execute(templateCharstrPattern());
970ed795
EL
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.052406 seconds and 5 git commands to generate.