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 TtemplateInt { | |
9 | type component templateInt_mycomp {}; | |
10 | type record templateInt_rec { | |
11 | integer x1, | |
12 | integer x2, | |
13 | integer x3 optional }; | |
14 | template templateInt_rec templateInt_tSpec :={ //specific values | |
15 | x1:=1, | |
16 | x2:=2, | |
17 | x3:=3 }; | |
18 | template templateInt_rec templateInt_tList :={ //specific value and value list | |
19 | x1:=1, | |
20 | x2:=(2,3,6), | |
21 | x3:=3 }; | |
22 | template templateInt_rec templateInt_tComp :={ //specific value and compl. list | |
23 | x1:=1, | |
24 | x2:=complement (2,3,6), | |
25 | x3:=3 }; | |
26 | template templateInt_rec templateInt_tOmit :={ //omitting values | |
27 | x1:=1, | |
28 | x2:=2, | |
29 | x3:=omit } ; | |
30 | template templateInt_rec templateInt_tAny :={ //specific and any value | |
31 | x1:=1, | |
32 | x2:=2, | |
33 | x3:=? } ; | |
34 | template templateInt_rec templateInt_tAnyorNone :={ //specific and AnyorNone value | |
35 | x1:=1, | |
36 | x2:=2, | |
37 | x3:=* }; | |
38 | template templateInt_rec templateInt_tRange1 :={ //specific value and Range | |
39 | x1:=1, | |
40 | x2:=(2 ..4), | |
41 | x3:=3 }; | |
42 | template templateInt_rec templateInt_tRange2 :={ //specific value and Range | |
43 | x1:=1, | |
44 | x2:=(2 .. 4), | |
45 | x3:=3 }; | |
46 | template templateInt_rec templateInt_tRange3 :={ //specific value and Range | |
47 | x1:=1, | |
48 | x2:=(2 .. infinity), | |
49 | x3:=3 }; | |
50 | template templateInt_rec templateInt_tRange4 :={ //specific value and Range | |
51 | x1:=1, | |
52 | x2:=(-infinity .. 4), | |
53 | x3:=3 }; | |
54 | template templateInt_rec templateInt_tIfpresent :={ //specific value and ifpresent | |
55 | x1:=1, | |
56 | x2:=2, | |
57 | x3:=3 ifpresent }; | |
58 | ||
59 | testcase templateIntSpec() runs on templateInt_mycomp { | |
60 | var templateInt_rec x1,x2; //specific value | |
61 | x1:={ x1:=1, x2:=2, x3:=3 }; | |
62 | x2:={ x1:=2, x2:=2, x3:=3 }; | |
63 | //match | |
64 | if (match(x1,templateInt_tSpec)) {setverdict(pass);} | |
65 | else {setverdict(fail);} | |
66 | //no match | |
67 | if (not(match(x2,templateInt_tSpec))) {setverdict(pass);} | |
68 | else {setverdict(fail);} | |
69 | } | |
70 | ||
71 | testcase templateIntList() runs on templateInt_mycomp { | |
72 | var templateInt_rec x1,x2,x3; //value list | |
73 | x1:={ x1:=1, x2:=6, x3:=3 }; | |
74 | x2:={ x1:=1, x2:=7, x3:=3 }; | |
75 | x3:={ x1:=2, x2:=6, x3:=3 }; | |
76 | //match | |
77 | if (match(x1,templateInt_tList)) {setverdict(pass);} | |
78 | else {setverdict(fail);} | |
79 | //no match: out of list | |
80 | if (not(match(x2,templateInt_tList))) {setverdict(pass);} | |
81 | else {setverdict(fail);} | |
82 | //no match: other field | |
83 | if (not(match(x3,templateInt_tList))) {setverdict(pass);} | |
84 | else {setverdict(fail);} | |
85 | } | |
86 | ||
87 | testcase templateIntComp() runs on templateInt_mycomp { | |
88 | var templateInt_rec x1,x2,x3; //complemented list | |
89 | x1:={ x1:=1, x2:=7, x3:=3 }; | |
90 | x2:={ x1:=1, x2:=6, x3:=3 }; | |
91 | x3:={ x1:=2, x2:=7, x3:=3 }; | |
92 | //match | |
93 | if (match(x1,templateInt_tComp)) {setverdict(pass);} | |
94 | else {setverdict(fail);} | |
95 | //no match: in the list | |
96 | if (not(match(x2,templateInt_tComp))) {setverdict(pass);} | |
97 | else {setverdict(fail);} | |
98 | //no match: other field | |
99 | if (not(match(x3,templateInt_tComp))) {setverdict(pass);} | |
100 | else {setverdict(fail);} | |
101 | } | |
102 | ||
103 | testcase templateIntOmit() runs on templateInt_mycomp { | |
104 | var templateInt_rec x1,x2,x3; //omitting value | |
105 | x1:={ x1:=1, x2:=2, x3:=omit }; | |
106 | x2:={ x1:=1, x2:=2, x3:=3 }; | |
107 | x3:={ x1:=2, x2:=2, x3:=omit }; | |
108 | //match | |
109 | if (match(x1,templateInt_tOmit)) {setverdict(pass);} | |
110 | else {setverdict(fail);} | |
111 | //no match: not omitted | |
112 | if (not(match(x2,templateInt_tOmit))) {setverdict(pass);} | |
113 | else {setverdict(fail);} | |
114 | //no match: other field | |
115 | if (not(match(x3,templateInt_tOmit))) {setverdict(pass);} | |
116 | else {setverdict(fail);} | |
117 | } | |
118 | ||
119 | testcase templateIntAny() runs on templateInt_mycomp { | |
120 | var templateInt_rec x1,x2,x3; //any value | |
121 | x1:={ x1:=1, x2:=2, x3:=3 }; | |
122 | x2:={ x1:=1, x2:=2, x3:=omit }; | |
123 | x3:={ x1:=2, x2:=2, x3:=3 }; | |
124 | //match | |
125 | if (match(x1,templateInt_tAny)) {setverdict(pass);} | |
126 | else {setverdict(fail);} | |
127 | //no match: field omitted | |
128 | if (not(match(x2,templateInt_tAny))) {setverdict(pass);} | |
129 | else {setverdict(fail);} | |
130 | //no match: other field | |
131 | if (not(match(x3,templateInt_tAny))) {setverdict(pass);} | |
132 | else {setverdict(fail);} | |
133 | } | |
134 | ||
135 | testcase templateIntAnyorNone() runs on templateInt_mycomp { | |
136 | var templateInt_rec x1,x2,x3; //AnyorNone value | |
137 | x1:={ x1:=1, x2:=2, x3:=omit }; | |
138 | x2:={ x1:=1, x2:=2, x3:=3 }; | |
139 | x3:={ x1:=2, x2:=2, x3:=omit }; | |
140 | //match: omitted | |
141 | if (match(x1,templateInt_tAnyorNone)) {setverdict(pass);} | |
142 | else {setverdict(fail);} | |
143 | //match: value | |
144 | if (match(x2,templateInt_tAnyorNone)) {setverdict(pass);} | |
145 | else {setverdict(fail);} | |
146 | //no match: other field | |
147 | if (not(match(x3,templateInt_tAnyorNone))) {setverdict(pass);} | |
148 | else {setverdict(fail);} | |
149 | } | |
150 | ||
151 | testcase templateIntRange1() runs on templateInt_mycomp { | |
152 | var templateInt_rec x1,x2,x3; //Range (x .. y) | |
153 | x1:={ x1:=1, x2:=2, x3:=3 }; | |
154 | x2:={ x1:=1, x2:=5, x3:=3 }; | |
155 | x3:={ x1:=2, x2:=2, x3:=3 }; | |
156 | //match | |
157 | if (match(x1,templateInt_tRange1)) {setverdict(pass);} | |
158 | else {setverdict(fail);} | |
159 | //no match: out of range | |
160 | if (not(match(x2,templateInt_tRange1))) {setverdict(pass);} | |
161 | else {setverdict(fail);} | |
162 | //no match: other field | |
163 | if (not(match(x3,templateInt_tRange1))) {setverdict(pass);} | |
164 | else {setverdict(fail);} | |
165 | } | |
166 | ||
167 | testcase templateIntRange2() runs on templateInt_mycomp { | |
168 | var templateInt_rec x1,x2,x3; //Range (x to y) | |
169 | x1:={ x1:=1, x2:=2, x3:=3 }; | |
170 | x2:={ x1:=1, x2:=5, x3:=3 }; | |
171 | x3:={ x1:=2, x2:=2, x3:=3 }; | |
172 | //match | |
173 | if (match(x1,templateInt_tRange2)) {setverdict(pass);} | |
174 | else {setverdict(fail);} | |
175 | //no match: out of range | |
176 | if (not(match(x2,templateInt_tRange2))) {setverdict(pass);} | |
177 | else {setverdict(fail);} | |
178 | //no match: other field | |
179 | if (not(match(x3,templateInt_tRange2))) {setverdict(pass);} | |
180 | else {setverdict(fail);} | |
181 | } | |
182 | ||
183 | testcase templateIntRange3() runs on templateInt_mycomp { | |
184 | var templateInt_rec x1,x2,x3; //Range, with infinity | |
185 | x1:={ x1:=1, x2:=8, x3:=3 }; | |
186 | x2:={ x1:=1, x2:=-5, x3:=3 }; | |
187 | x3:={ x1:=2, x2:=2, x3:=3 }; | |
188 | //match | |
189 | if (match(x1,templateInt_tRange3)) {setverdict(pass);} | |
190 | else {setverdict(fail);} | |
191 | //no match: out of range | |
192 | if (not(match(x2,templateInt_tRange3))) {setverdict(pass);} | |
193 | else {setverdict(fail);} | |
194 | //no match: other field | |
195 | if (not(match(x3,templateInt_tRange3))) {setverdict(pass);} | |
196 | else {setverdict(fail);} | |
197 | } | |
198 | ||
199 | testcase templateIntRange4() runs on templateInt_mycomp { | |
200 | var templateInt_rec x1,x2,x3; //Range with - infinity | |
201 | x1:={ x1:=1, x2:=-2, x3:=3 }; | |
202 | x2:={ x1:=1, x2:=5, x3:=3 }; | |
203 | x3:={ x1:=2, x2:=2, x3:=3 }; | |
204 | //match | |
205 | if (match(x1,templateInt_tRange4)) {setverdict(pass);} | |
206 | else {setverdict(fail);} | |
207 | //no match: out of range | |
208 | if (not(match(x2,templateInt_tRange4))) {setverdict(pass);} | |
209 | else {setverdict(fail);} | |
210 | //no match: other field | |
211 | if (not(match(x3,templateInt_tRange4))) {setverdict(pass);} | |
212 | else {setverdict(fail);} | |
213 | } | |
214 | ||
215 | testcase templateIntIfpresent() runs on templateInt_mycomp { | |
216 | var templateInt_rec x1,x2,x3,x4; //ifpresent | |
217 | x1:={ x1:=1, x2:=2, x3:=3 }; | |
218 | x2:={ x1:=1, x2:=2, x3:=omit }; | |
219 | x3:={ x1:=1, x2:=2, x3:=4 }; | |
220 | x4:={ x1:=2, x2:=2, x3:=omit }; | |
221 | //match: present and match | |
222 | if (match(x1,templateInt_tIfpresent)) {setverdict(pass);} | |
223 | else {setverdict(fail);} | |
224 | //match: not present | |
225 | if (match(x2,templateInt_tIfpresent)) {setverdict(pass);} | |
226 | else {setverdict(fail);} | |
227 | //no match: present and not match | |
228 | if (not(match(x3,templateInt_tIfpresent))) {setverdict(pass);} | |
229 | else {setverdict(fail);} | |
230 | //no match: other field | |
231 | if (not(match(x4,templateInt_tIfpresent))) {setverdict(pass);} | |
232 | else {setverdict(fail);} | |
233 | } | |
234 | ||
235 | // Types for TR_HJ94652. | |
236 | type record TR_HJ94652_myrec { | |
237 | integer myrecint | |
238 | } | |
239 | ||
240 | template TR_HJ94652_myrec TR_HJ94652_mytemp(integer myint) := { | |
241 | myrecint := (myint - 100 .. myint) | |
242 | } | |
243 | ||
244 | type record of TR_HJ94652_myrec TR_HJ94652_mylist | |
245 | ||
246 | testcase TR_HJ94652() runs on templateInt_mycomp { | |
247 | // INTEGER_template::copy_template() was not implemented correctly for | |
248 | // VALUE_RANGE templates. | |
249 | var template TR_HJ94652_mylist myownlist := { } | |
250 | for (var integer i := 1; i <= 3; i := i + 1) { | |
251 | myownlist[i] := TR_HJ94652_mytemp(i * 100) | |
252 | } | |
253 | for (var integer i := 1; i <= 3; i := i + 1) { | |
254 | var charstring s1 := log2str(myownlist[i]) | |
255 | var charstring s2 := log2str(TR_HJ94652_mytemp(i * 100)) | |
256 | if (s1 == s2) { setverdict(pass) } | |
257 | else { setverdict(fail) } | |
258 | } | |
259 | } | |
260 | ||
261 | control { | |
262 | execute(templateIntSpec()); | |
263 | execute(templateIntList()); | |
264 | execute(templateIntComp()); | |
265 | execute(templateIntOmit()); | |
266 | execute(templateIntAny()); | |
267 | execute(templateIntAnyorNone()); | |
268 | execute(templateIntRange1()); | |
269 | execute(templateIntRange2()); | |
270 | execute(templateIntRange3()); | |
271 | execute(templateIntRange4()); | |
272 | execute(templateIntIfpresent()); | |
273 | execute(TR_HJ94652()); | |
274 | } | |
275 | } |