Sync with 5.4.0
[deliverable/titan.core.git] / regression_test / templateChar / TtemplateChar.ttcn
CommitLineData
970ed795 1/******************************************************************************
3abe9331 2 * Copyright (c) 2000-2015 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
7 ******************************************************************************/
8module TtemplateChar {
9type component templateChar_mycomp {};
10type record templateChar_rec {
11 char x1,
12 char x2,
13 char x3 optional };
14template templateChar_rec templateChar_tSpec :={ //specific values
15 x1:="a",
16 x2:="b",
17 x3:="c" };
18template templateChar_rec templateChar_tList :={ //specific value and value list
19 x1:="a",
20 x2:=("a","b","k"),
21 x3:="c" };
22template templateChar_rec templateChar_tComp :={ //specific value and compl. list
23 x1:="a",
24 x2:=complement ("b","2","l"),
25 x3:="c" };
26template templateChar_rec templateChar_tOmit :={ //omitting values
27 x1:="a",
28 x2:="b",
29 x3:=omit } ;
30template templateChar_rec templateChar_tAny :={ //specific and any value
31 x1:="a",
32 x2:="b",
33 x3:=? } ;
34template templateChar_rec templateChar_tAnyorNone :={ //specific and AnyorNone value
35 x1:="a",
36 x2:="b",
37 x3:=* };
38template templateChar_rec templateChar_tRange1 :={ //specific value and Range
39 x1:="a",
40 x2:=("a" .."h"),
41 x3:="c" };
42template templateChar_rec templateChar_tRange2 :={ //specific value and Range
43 x1:="a",
44 x2:=("a" .. "h"),
45 x3:="c" };
46template templateChar_rec templateChar_tRange3 :={ //specific value and Range
47 x1:="a",
48 x2:=("k" .. int2char(127)),
49 x3:="c" };
50template templateChar_rec templateChar_tRange4 :={ //specific value and Range
51 x1:="a",
52 x2:=(int2char(0) .. "k"),
53 x3:="c" };
54template templateChar_rec templateChar_tIfpresent :={ //specific value and ifpresent
55 x1:="a",
56 x2:="b",
57 x3:="c" ifpresent };
58
59testcase templateCharSpec() runs on templateChar_mycomp {
60var templateChar_rec x1,x2; //specific value
61x1:={ x1:="a", x2:="b", x3:="c" };
62x2:={ x1:="k", x2:="b", x3:="c" };
63//match
64if (match(x1,templateChar_tSpec)) {setverdict(pass);}
65 else {setverdict(fail);}
66//no match
67if (not(match(x2,templateChar_tSpec))) {setverdict(pass);}
68 else {setverdict(fail);}
69}
70
71testcase templateCharList() runs on templateChar_mycomp {
72var templateChar_rec x1,x2,x3; //value list
73x1:={ x1:="a", x2:="b", x3:="c" };
74x2:={ x1:="a", x2:="h", x3:="c" };
75x3:={ x1:="k", x2:="b", x3:="c" };
76//match
77if (match(x1,templateChar_tList)) {setverdict(pass);}
78 else {setverdict(fail);}
79//no match: out of list
80if (not(match(x2,templateChar_tList))) {setverdict(pass);}
81 else {setverdict(fail);}
82//no match: other field
83if (not(match(x3,templateChar_tList))) {setverdict(pass);}
84 else {setverdict(fail);}
85}
86
87testcase templateCharComp() runs on templateChar_mycomp {
88var templateChar_rec x1,x2,x3; //complemented list
89x1:={ x1:="a", x2:="c", x3:="c" };
90x2:={ x1:="a", x2:="2", x3:="c" };
91x3:={ x1:="k", x2:="c", x3:="c" };
92//match
93if (match(x1,templateChar_tComp)) {setverdict(pass);}
94 else {setverdict(fail);}
95//no match: in the list
96if (not(match(x2,templateChar_tComp))) {setverdict(pass);}
97 else {setverdict(fail);}
98//no match: other field
99if (not(match(x3,templateChar_tComp))) {setverdict(pass);}
100 else {setverdict(fail);}
101}
102
103testcase templateCharOmit() runs on templateChar_mycomp {
104var templateChar_rec x1,x2,x3; //omitting value
105x1:={ x1:="a", x2:="b", x3:=omit };
106x2:={ x1:="a", x2:="b", x3:="o" };
107x3:={ x1:="l", x2:="b", x3:=omit };
108//match
109if (match(x1,templateChar_tOmit)) {setverdict(pass);}
110 else {setverdict(fail);}
111//no match: not omitted
112if (not(match(x2,templateChar_tOmit))) {setverdict(pass);}
113 else {setverdict(fail);}
114//no match: other field
115if (not(match(x3,templateChar_tOmit))) {setverdict(pass);}
116 else {setverdict(fail);}
117}
118
119testcase templateCharAny() runs on templateChar_mycomp {
120var templateChar_rec x1,x2,x3; //any value
121x1:={ x1:="a", x2:="b", x3:="l" };
122x2:={ x1:="a", x2:="b", x3:=omit };
123x3:={ x1:="k", x2:="b", x3:="l" };
124//match
125if (match(x1,templateChar_tAny)) {setverdict(pass);}
126 else {setverdict(fail);}
127//no match: field omitted
128if (not(match(x2,templateChar_tAny))) {setverdict(pass);}
129 else {setverdict(fail);}
130//no match: other field
131if (not(match(x3,templateChar_tAny))) {setverdict(pass);}
132 else {setverdict(fail);}
133}
134
135testcase templateCharAnyorNone() runs on templateChar_mycomp {
136var templateChar_rec x1,x2,x3; //AnyorNone value
137x1:={ x1:="a", x2:="b", x3:=omit };
138x2:={ x1:="a", x2:="b", x3:="m" };
139x3:={ x1:="p", x2:="b", x3:=omit };
140//match: omitted
141if (match(x1,templateChar_tAnyorNone)) {setverdict(pass);}
142 else {setverdict(fail);}
143//match: value
144if (match(x2,templateChar_tAnyorNone)) {setverdict(pass);}
145 else {setverdict(fail);}
146//no match: other field
147if (not(match(x3,templateChar_tAnyorNone))) {setverdict(pass);}
148 else {setverdict(fail);}
149}
150
151testcase templateCharRange1() runs on templateChar_mycomp {
152var templateChar_rec x1,x2,x3; //Range ( .. )
153x1:={ x1:="a", x2:="d", x3:="c" };
154x2:={ x1:="a", x2:="p", x3:="c" };
155x3:={ x1:="l", x2:="d", x3:="c" };
156//match
157if (match(x1,templateChar_tRange1)) {setverdict(pass);}
158 else {setverdict(fail);}
159//no match: out of range
160if (not(match(x2,templateChar_tRange1))) {setverdict(pass);}
161 else {setverdict(fail);}
162//no match: other field
163if (not(match(x3,templateChar_tRange1))) {setverdict(pass);}
164 else {setverdict(fail);}
165}
166
167testcase templateCharRange2() runs on templateChar_mycomp {
168var templateChar_rec x1,x2,x3; //Range ( to )
169x1:={ x1:="a", x2:="d", x3:="c" };
170x2:={ x1:="a", x2:="p", x3:="c" };
171x3:={ x1:="l", x2:="d", x3:="c" };
172//match
173if (match(x1,templateChar_tRange2)) {setverdict(pass);}
174 else {setverdict(fail);}
175//no match: out of range
176if (not(match(x2,templateChar_tRange2))) {setverdict(pass);}
177 else {setverdict(fail);}
178//no match: other field
179if (not(match(x3,templateChar_tRange2))) {setverdict(pass);}
180 else {setverdict(fail);}
181}
182
183testcase templateCharRange3() runs on templateChar_mycomp {
184var templateChar_rec x1,x2,x3; //Range, with infinity
185x1:={ x1:="a", x2:="p", x3:="c" };
186x2:={ x1:="a", x2:="d", x3:="c" };
187x3:={ x1:="l", x2:="p", x3:="c" };
188//match
189if (match(x1,templateChar_tRange3)) {setverdict(pass);}
190 else {setverdict(fail);}
191//no match: out of range
192if (not(match(x2,templateChar_tRange3))) {setverdict(pass);}
193 else {setverdict(fail);}
194//no match: other field
195if (not(match(x3,templateChar_tRange3))) {setverdict(pass);}
196 else {setverdict(fail);}
197}
198
199testcase templateCharRange4() runs on templateChar_mycomp {
200var templateChar_rec x1,x2,x3; //Range with - infinity
201x1:={ x1:="a", x2:="d", x3:="c" };
202x2:={ x1:="a", x2:="p", x3:="c" };
203x3:={ x1:="l", x2:="d", x3:="c" };
204//match
205if (match(x1,templateChar_tRange4)) {setverdict(pass);}
206 else {setverdict(fail);}
207//no match: out of range
208if (not(match(x2,templateChar_tRange4))) {setverdict(pass);}
209 else {setverdict(fail);}
210//no match: other field
211if (not(match(x3,templateChar_tRange4))) {setverdict(pass);}
212 else {setverdict(fail);}
213}
214
215testcase templateCharIfpresent() runs on templateChar_mycomp {
216var templateChar_rec x1,x2,x3,x4; //ifpresent
217x1:={ x1:="a", x2:="b", x3:="c" };
218x2:={ x1:="a", x2:="b", x3:=omit };
219x3:={ x1:="a", x2:="b", x3:="k" };
220x4:={ x1:="c", x2:="b", x3:=omit };
221//match: present and match
222if (match(x1,templateChar_tIfpresent)) {setverdict(pass);}
223 else {setverdict(fail);}
224//match: not present
225if (match(x2,templateChar_tIfpresent)) {setverdict(pass);}
226 else {setverdict(fail);}
227//no match: present and not match
228if (not(match(x3,templateChar_tIfpresent))) {setverdict(pass);}
229 else {setverdict(fail);}
230//no match: other field
231if (not(match(x4,templateChar_tIfpresent))) {setverdict(pass);}
232 else {setverdict(fail);}
233}
234
235control {
236 execute(templateCharSpec());
237 execute(templateCharList());
238 execute(templateCharComp());
239 execute(templateCharOmit());
240 execute(templateCharAny());
241 execute(templateCharAnyorNone());
242 execute(templateCharRange1());
243 execute(templateCharRange2());
244 execute(templateCharRange3());
245 execute(templateCharRange4());
246 execute(templateCharIfpresent());
247}
248}
This page took 0.057087 seconds and 5 git commands to generate.