Commit | Line | Data |
---|---|---|
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 | ******************************************************************************/ | |
8 | module TtemplateOctetstr { | |
9 | type component templateOctetstr_mycomp {}; | |
10 | type record templateOctetstr_rec { | |
11 | octetstring x1, | |
12 | octetstring x2, | |
13 | octetstring x3 optional }; | |
14 | template templateOctetstr_rec templateOctetstr_tSpec :={ //specific values | |
15 | x1:='00AA'O, | |
16 | x2:='01AA'O, | |
17 | x3:='10AA'O }; | |
18 | template templateOctetstr_rec templateOctetstr_tList :={ //specific value and value list | |
19 | x1:='00AA'O, | |
20 | x2:=('01AA'O,'01AB'O,'11AC'O), | |
21 | x3:='10AA'O }; | |
22 | template templateOctetstr_rec templateOctetstr_tComp :={ //specific value and compl. list | |
23 | x1:='00AA'O, | |
24 | x2:=complement ('11'O,'0A'O,'1BC0'O), | |
25 | x3:='10AA'O }; | |
26 | template templateOctetstr_rec templateOctetstr_tOmit :={ //omitting values | |
27 | x1:='00AA'O, | |
28 | x2:='01AA'O, | |
29 | x3:=omit } ; | |
30 | template templateOctetstr_rec templateOctetstr_tAny :={ //specific and any value | |
31 | x1:='00AA'O, | |
32 | x2:='01AA'O, | |
33 | x3:=? } ; | |
34 | template templateOctetstr_rec templateOctetstr_tAnyorNone :={ //specific and AnyorNone value | |
35 | x1:='00AA'O, | |
36 | x2:='01AA'O, | |
37 | x3:=* }; | |
38 | template templateOctetstr_rec templateOctetstr_tLength1 :={ //specific value and fix length | |
39 | x1:='00AA'O, | |
40 | x2:='01AA'O, | |
41 | x3:=* length(3) }; | |
42 | template templateOctetstr_rec templateOctetstr_tLength2 :={ //specific value and length (range) | |
43 | x1:='00AA'O, | |
44 | x2:='01AA'O, | |
45 | x3:=? length(2..4) }; | |
46 | template templateOctetstr_rec templateOctetstr_tLength3 :={ //specific value and length (range, infinity) | |
47 | x1:='00AA'O, | |
48 | x2:='01AA'O, | |
49 | x3:=? length(2..infinity) }; | |
50 | template templateOctetstr_rec templateOctetstr_tIfpresent :={ //specific value and ifpresent | |
51 | x1:='00AA'O, | |
52 | x2:='01AA'O, | |
53 | x3:='10AA'O ifpresent }; | |
54 | template templateOctetstr_rec templateOctetstr_tLengthIfp :={ //specific value and length (range) and IfPresent | |
55 | x1:='00AA'O, | |
56 | x2:='01AA'O, | |
57 | x3:=? length(2..4) ifpresent}; | |
58 | template templateOctetstr_rec templateOctetstr_tAnyEl :={ //specific value and any element inside value | |
59 | x1:='00AA'O, | |
60 | x2:='01AA'O, | |
61 | x3:='10?'O } ; | |
62 | template templateOctetstr_rec templateOctetstr_tAnyorNoneEl :={ //specific value and Any number of elements or none inside value | |
63 | x1:='00AA'O, | |
64 | x2:='01AA'O, | |
65 | x3:='10*'O }; | |
66 | ||
67 | testcase templateOctetstrSpec() runs on templateOctetstr_mycomp { | |
68 | var templateOctetstr_rec x1,x2; //specific value | |
69 | x1:={ x1:='00AA'O, x2:='01AA'O, x3:='10AA'O }; | |
70 | x2:={ x1:='00BC'O, x2:='01AA'O, x3:='10AA'O }; | |
71 | //match | |
72 | if (match(x1,templateOctetstr_tSpec)) {setverdict(pass);} | |
73 | else {setverdict(fail);} | |
74 | //no match | |
75 | if (not(match(x2,templateOctetstr_tSpec))) {setverdict(pass);} | |
76 | else {setverdict(fail);} | |
77 | } | |
78 | ||
79 | testcase templateOctetstrList() runs on templateOctetstr_mycomp { | |
80 | var templateOctetstr_rec x1,x2,x3; //value list | |
81 | x1:={ x1:='00AA'O, x2:='01AA'O, x3:='10AA'O }; | |
82 | x2:={ x1:='00AA'O, x2:='00'O, x3:='10AA'O }; | |
83 | x3:={ x1:='1D'O, x2:='01AA'O, x3:='10AA'O }; | |
84 | //match | |
85 | if (match(x1,templateOctetstr_tList)) {setverdict(pass);} | |
86 | else {setverdict(fail);} | |
87 | //no match: out of list | |
88 | if (not(match(x2,templateOctetstr_tList))) {setverdict(pass);} | |
89 | else {setverdict(fail);} | |
90 | //no match: other field | |
91 | if (not(match(x3,templateOctetstr_tList))) {setverdict(pass);} | |
92 | else {setverdict(fail);} | |
93 | } | |
94 | ||
95 | testcase templateOctetstrComp() runs on templateOctetstr_mycomp { | |
96 | var templateOctetstr_rec x1,x2,x3; //complemented list | |
97 | x1:={ x1:='00AA'O, x2:='01AA'O, x3:='10AA'O }; | |
98 | x2:={ x1:='00AA'O, x2:='0A'O, x3:='10AA'O }; | |
99 | x3:={ x1:='11AA'O, x2:='01AA'O, x3:='10AA'O }; | |
100 | //match | |
101 | if (match(x1,templateOctetstr_tComp)) {setverdict(pass);} | |
102 | else {setverdict(fail);} | |
103 | //no match: in the list | |
104 | if (not(match(x2,templateOctetstr_tComp))) {setverdict(pass);} | |
105 | else {setverdict(fail);} | |
106 | //no match: other field | |
107 | if (not(match(x3,templateOctetstr_tComp))) {setverdict(pass);} | |
108 | else {setverdict(fail);} | |
109 | } | |
110 | ||
111 | testcase templateOctetstrOmit() runs on templateOctetstr_mycomp { | |
112 | var templateOctetstr_rec x1,x2,x3; //omitting value | |
113 | x1:={ x1:='00AA'O, x2:='01AA'O, x3:=omit }; | |
114 | x2:={ x1:='00AA'O, x2:='01AA'O, x3:='AB'O }; | |
115 | x3:={ x1:='00DE'O, x2:='01AA'O, x3:=omit }; | |
116 | //match | |
117 | if (match(x1,templateOctetstr_tOmit)) {setverdict(pass);} | |
118 | else {setverdict(fail);} | |
119 | //no match: not omitted | |
120 | if (not(match(x2,templateOctetstr_tOmit))) {setverdict(pass);} | |
121 | else {setverdict(fail);} | |
122 | //no match: other field | |
123 | if (not(match(x3,templateOctetstr_tOmit))) {setverdict(pass);} | |
124 | else {setverdict(fail);} | |
125 | } | |
126 | ||
127 | testcase templateOctetstrAny() runs on templateOctetstr_mycomp { | |
128 | var templateOctetstr_rec x1,x2,x3; //any value | |
129 | x1:={ x1:='00AA'O, x2:='01AA'O, x3:='ABCD'O }; | |
130 | x2:={ x1:='00AA'O, x2:='01AA'O, x3:=omit }; | |
131 | x3:={ x1:='0A'O, x2:='01AA'O, x3:='ABCD'O }; | |
132 | //match | |
133 | if (match(x1,templateOctetstr_tAny)) {setverdict(pass);} | |
134 | else {setverdict(fail);} | |
135 | //no match: field omitted | |
136 | if (not(match(x2,templateOctetstr_tAny))) {setverdict(pass);} | |
137 | else {setverdict(fail);} | |
138 | //no match: other field | |
139 | if (not(match(x3,templateOctetstr_tAny))) {setverdict(pass);} | |
140 | else {setverdict(fail);} | |
141 | } | |
142 | ||
143 | testcase templateOctetstrAnyorNone() runs on templateOctetstr_mycomp { | |
144 | var templateOctetstr_rec x1,x2,x3; //AnyorNone value | |
145 | x1:={ x1:='00AA'O, x2:='01AA'O, x3:=omit }; | |
146 | x2:={ x1:='00AA'O, x2:='01AA'O, x3:='10AB'O }; | |
147 | x3:={ x1:='1C'O, x2:='01AA'O, x3:=omit }; | |
148 | //match: omitted | |
149 | if (match(x1,templateOctetstr_tAnyorNone)) {setverdict(pass);} | |
150 | else {setverdict(fail);} | |
151 | //match: value | |
152 | if (match(x2,templateOctetstr_tAnyorNone)) {setverdict(pass);} | |
153 | else {setverdict(fail);} | |
154 | //no match: other field | |
155 | if (not(match(x3,templateOctetstr_tAnyorNone))) {setverdict(pass);} | |
156 | else {setverdict(fail);} | |
157 | } | |
158 | ||
159 | testcase templateOctetstrLength1() runs on templateOctetstr_mycomp { | |
160 | var templateOctetstr_rec x1,x2,x3,x4; //length(fix) | |
161 | x1:={ x1:='00AA'O, x2:='01AA'O, x3:='11AABC'O }; | |
162 | x2:={ x1:='00AA'O, x2:='01AA'O, x3:=omit }; | |
163 | x3:={ x1:='00AA'O, x2:='01AA'O, x3:='1D'O }; | |
164 | x4:={ x1:='001A'O, x2:='01AA'O, x3:='11AABB'O }; | |
165 | //match: proper length | |
166 | if (match(x1,templateOctetstr_tLength1)) {setverdict(pass);} | |
167 | else {setverdict(fail);} | |
168 | //match: omitted | |
169 | if (match(x2,templateOctetstr_tLength1)) {setverdict(pass);} | |
170 | else {setverdict(fail);} | |
171 | // no match: not proper length | |
172 | if (not(match(x3,templateOctetstr_tLength1))) {setverdict(pass);} | |
173 | else {setverdict(fail);} | |
174 | //no match: other field | |
175 | if (not(match(x4,templateOctetstr_tLength1))) {setverdict(pass);} | |
176 | else {setverdict(fail);} | |
177 | } | |
178 | ||
179 | testcase templateOctetstrLength2() runs on templateOctetstr_mycomp { | |
180 | var templateOctetstr_rec x1,x2,x3; //length (range) | |
181 | x1:={ x1:='00AA'O, x2:='01AA'O, x3:='11AABB'O }; | |
182 | x2:={ x1:='00AA'O, x2:='01AA'O, x3:='1C'O }; | |
183 | x3:={ x1:='001A'O, x2:='01AA'O, x3:='11AABB'O }; | |
184 | //match | |
185 | if (match(x1,templateOctetstr_tLength2)) {setverdict(pass);} | |
186 | else {setverdict(fail);} | |
187 | // no match: not proper length | |
188 | if (not(match(x2,templateOctetstr_tLength2))) {setverdict(pass);} | |
189 | else {setverdict(fail);} | |
190 | //no match: other field | |
191 | if (not(match(x3,templateOctetstr_tLength2))) {setverdict(pass);} | |
192 | else {setverdict(fail);} | |
193 | } | |
194 | ||
195 | testcase templateOctetstrLength3() runs on templateOctetstr_mycomp { | |
196 | var templateOctetstr_rec x1,x2,x3; //length (range, infinity) | |
197 | x1:={ x1:='00AA'O, x2:='01AA'O, x3:='11AABB'O }; | |
198 | x2:={ x1:='00AA'O, x2:='01AA'O, x3:='1C'O }; | |
199 | x3:={ x1:='001A'O, x2:='01AA'O, x3:='11AABB'O }; | |
200 | //match | |
201 | if (match(x1,templateOctetstr_tLength3)) {setverdict(pass);} | |
202 | else {setverdict(fail);} | |
203 | // no match: not proper length | |
204 | if (not(match(x2,templateOctetstr_tLength3))) {setverdict(pass);} | |
205 | else {setverdict(fail);} | |
206 | //no match: other field | |
207 | if (not(match(x3,templateOctetstr_tLength3))) {setverdict(pass);} | |
208 | else {setverdict(fail);} | |
209 | } | |
210 | ||
211 | testcase templateOctetstrIfpresent() runs on templateOctetstr_mycomp { | |
212 | var templateOctetstr_rec x1,x2,x3,x4; //ifpresent | |
213 | x1:={ x1:='00AA'O, x2:='01AA'O, x3:='10AA'O }; | |
214 | x2:={ x1:='00AA'O, x2:='01AA'O, x3:=omit }; | |
215 | x3:={ x1:='00AA'O, x2:='01AA'O, x3:='00AA'O }; | |
216 | x4:={ x1:='00'O, x2:='01AA'O, x3:=omit }; | |
217 | //match: present and match | |
218 | if (match(x1,templateOctetstr_tIfpresent)) {setverdict(pass);} | |
219 | else {setverdict(fail);} | |
220 | //match: not present | |
221 | if (match(x2,templateOctetstr_tIfpresent)) {setverdict(pass);} | |
222 | else {setverdict(fail);} | |
223 | //no match: present and not match | |
224 | if (not(match(x3,templateOctetstr_tIfpresent))) {setverdict(pass);} | |
225 | else {setverdict(fail);} | |
226 | //no match: other field | |
227 | if (not(match(x4,templateOctetstr_tIfpresent))) {setverdict(pass);} | |
228 | else {setverdict(fail);} | |
229 | } | |
230 | ||
231 | testcase templateOctetstrLengthIfp() runs on templateOctetstr_mycomp { | |
232 | var templateOctetstr_rec x1,x2,x3,x4; //length(fix), ifpresent | |
233 | x1:={ x1:='00AA'O, x2:='01AA'O, x3:='11AABC'O }; | |
234 | x2:={ x1:='00AA'O, x2:='01AA'O, x3:=omit }; | |
235 | x3:={ x1:='00AA'O, x2:='01AA'O, x3:='1D'O }; | |
236 | x4:={ x1:='001A'O, x2:='01AA'O, x3:='11AABB'O }; | |
237 | //match: proper length | |
238 | if (match(x1,templateOctetstr_tLengthIfp)) {setverdict(pass);} | |
239 | else {setverdict(fail);} | |
240 | //match: omitted | |
241 | if (match(x2,templateOctetstr_tLengthIfp)) {setverdict(pass);} | |
242 | else {setverdict(fail);} | |
243 | // no match: not proper length | |
244 | if (not(match(x3,templateOctetstr_tLengthIfp))) {setverdict(pass);} | |
245 | else {setverdict(fail);} | |
246 | //no match: other field | |
247 | if (not(match(x4,templateOctetstr_tLengthIfp))) {setverdict(pass);} | |
248 | else {setverdict(fail);} | |
249 | } | |
250 | ||
251 | testcase templateOctetstrAnyEl() runs on templateOctetstr_mycomp { | |
252 | var templateOctetstr_rec x1,x2,x3,x4,x5; //any element | |
253 | x1:={ x1:='00AA'O, x2:='01AA'O, x3:='10AA'O }; | |
254 | x2:={ x1:='00AA'O, x2:='01AA'O, x3:='10'O }; | |
255 | x3:={ x1:='00AA'O, x2:='01AA'O, x3:='10AABB'O }; | |
256 | x4:={ x1:='00AA'O, x2:='01AA'O, x3:='1BAA'O }; | |
257 | x5:={ x1:='0A'O, x2:='01AA'O, x3:='10AA'O }; | |
258 | //match | |
259 | if (match(x1,templateOctetstr_tAnyEl)) {setverdict(pass);} | |
260 | else {setverdict(fail);} | |
261 | //no match: no element | |
262 | if (not(match(x2,templateOctetstr_tAnyEl))) {setverdict(pass);} | |
263 | else {setverdict(fail);} | |
264 | //no match: two element | |
265 | if (not(match(x3,templateOctetstr_tAnyEl))) {setverdict(pass);} | |
266 | else {setverdict(fail);} | |
267 | //no match: wrong element | |
268 | if (not(match(x4,templateOctetstr_tAnyEl))) {setverdict(pass);} | |
269 | else {setverdict(fail);} | |
270 | //no match: other field | |
271 | if (not(match(x5,templateOctetstr_tAnyEl))) {setverdict(pass);} | |
272 | else {setverdict(fail);} | |
273 | } | |
274 | ||
275 | testcase templateOctetstrAnyorNoneEl() runs on templateOctetstr_mycomp { | |
276 | var templateOctetstr_rec x1,x2,x3,x4,x5; //Any numb. of elements or none | |
277 | x1:={ x1:='00AA'O, x2:='01AA'O, x3:='10'O }; | |
278 | x2:={ x1:='00AA'O, x2:='01AA'O, x3:='10AA'O }; | |
279 | x3:={ x1:='00AA'O, x2:='01AA'O, x3:='10AABB'O }; | |
280 | x4:={ x1:='00AA'O, x2:='01AA'O, x3:='11AA'O }; | |
281 | x5:={ x1:='1A'O, x2:='01AA'O, x3:='10AA'O }; | |
282 | //match: no element | |
283 | if (match(x1,templateOctetstr_tAnyorNoneEl)) {setverdict(pass);} | |
284 | else {setverdict(fail);} | |
285 | //match: one element | |
286 | if (match(x2,templateOctetstr_tAnyorNoneEl)) {setverdict(pass);} | |
287 | else {setverdict(fail);} | |
288 | //match: two element | |
289 | if (match(x3,templateOctetstr_tAnyorNoneEl)) {setverdict(pass);} | |
290 | else {setverdict(fail);} | |
291 | //no match: wrong element | |
292 | if (not(match(x4,templateOctetstr_tAnyorNoneEl))) {setverdict(pass);} | |
293 | else {setverdict(fail);} | |
294 | //no match: other field | |
295 | if (not(match(x5,templateOctetstr_tAnyorNoneEl))) {setverdict(pass);} | |
296 | else {setverdict(fail);} | |
297 | } | |
298 | ||
299 | testcase CR_TR00018474() runs on templateOctetstr_mycomp { | |
300 | // Indexing of string template variables. | |
301 | var template octetstring vto1 := 'ABBAABBA'O | |
302 | var template octetstring vto2 := 'AABB??*'O // It's a pattern, cannot be indexed. | |
303 | vto1[0] := 'BB'O | |
304 | if (match('BBBAABBA'O, vto1)) { setverdict(pass) } else { setverdict(fail) } | |
305 | vto1[0] := 'BB'O // Indexed assignment notation cannot be used here. | |
306 | vto1[1] := 'BA'O // Still works, nothing special. | |
307 | if (match('BBBAABBA'O, vto1)) { setverdict(pass) } else { setverdict(fail) } | |
308 | } | |
309 | ||
310 | control { | |
311 | execute(templateOctetstrSpec()); | |
312 | execute(templateOctetstrList()); | |
313 | execute(templateOctetstrComp()); | |
314 | execute(templateOctetstrOmit()); | |
315 | execute(templateOctetstrAny()); | |
316 | execute(templateOctetstrAnyorNone()); | |
317 | execute(templateOctetstrLength1()); | |
318 | execute(templateOctetstrLength2()); | |
319 | execute(templateOctetstrLength3()); | |
320 | execute(templateOctetstrIfpresent()); | |
321 | execute(templateOctetstrLengthIfp()); | |
322 | execute(templateOctetstrAnyEl()); | |
323 | execute(templateOctetstrAnyorNoneEl()); | |
324 | execute(CR_TR00018474()); | |
325 | } | |
326 | } |