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