Sync with 5.1.0
[deliverable/titan.core.git] / regression_test / predefFunction / length_of_OK.ttcn
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 length_of_OK {
9
10 type component PDTestComponent {};
11
12 /*--- LENGTH OF BITSTRING --------------------------------------------------*/
13
14 const bitstring lofb := '1110001100'B
15 const bitstring lofb1 := ''B
16
17 modulepar integer lofbi := lengthof(lofb & lofb)
18 modulepar integer lofbi1 := lengthof(substr(lofb,0,lengthof(lofb)))
19 modulepar integer lofbi2 := lengthof(substr(lofb,0,lengthof(lofb)/2))
20 modulepar integer lofbi3 := lengthof(lofb & lofb1)
21 modulepar integer lofbi4 := lengthof(lofb1 & lofb1)
22 modulepar integer lofbi5 := lengthof(substr(lofb1,0,lengthof(lofb1)))
23
24 testcase lengthof_bitstr() runs on PDTestComponent{
25
26 if ((lofbi == 2*lengthof(lofb))
27 and (lofbi == lengthof(lofb & lofb)))
28 {setverdict(pass);}
29 else {setverdict(fail);}
30 if ((lofbi1 == lengthof(lofb))
31 and (lofbi1 == lengthof(substr(lofb,0,lengthof(lofb)))))
32 {setverdict(pass);}
33 else {setverdict(fail);}
34 if ((lofbi2 == 5)
35 and (lofbi2 == lengthof(substr(lofb,0,lengthof(lofb)/2))))
36 {setverdict(pass);}
37 else {setverdict(fail);}
38 if ((lofbi3 == 10)
39 and (lofbi3 == lengthof(lofb & lofb1)))
40 {setverdict(pass);}
41 else {setverdict(fail);}
42 if ((lofbi4 == 0)
43 and (lofbi4 == lengthof(lofb1 & lofb1)))
44 {setverdict(pass);}
45 else {setverdict(fail);}
46 if ((lofbi5 == 0)
47 and (lofbi5 == lengthof(substr(lofb1,0,lengthof(lofb1)))))
48 {setverdict(pass);}
49 else {setverdict(fail);}
50
51 var integer j;
52 var bitstring bb,b := ''B;
53
54 for (j:=0; j<lengthof(lofb); j:=j+1) {
55 b := b & lofb
56 if (lengthof(b) == (j+1)*lengthof(lofb))
57 {setverdict(pass);}
58 else {setverdict(fail);}
59 }
60
61 for (j:=lengthof(b); j>=0; j:=j-1) {
62 bb := substr(b,0,j)
63 if (lengthof(bb) == j)
64 {setverdict(pass);}
65 else {setverdict(fail);}
66 }
67
68 b := ''B
69 for (j:=1; j<4096; j:=j+1) {
70 b := b & int2bit(j,12)
71 if (lengthof(b) == j*12)
72 {setverdict(pass);}
73 else {setverdict(fail);}
74 bb :=int2bit(j,j)
75 if (lengthof(bb) == j)
76 {setverdict(pass);}
77 else {setverdict(fail);}
78 }
79 }
80
81 /*--- LENGTH OF HEXSTRING --------------------------------------------------*/
82
83 const hexstring lofh := '1110001100'H
84 const hexstring lofh1 := ''H
85
86 modulepar integer lofhi := lengthof(lofh & lofh)
87 modulepar integer lofhi1 := lengthof(substr(lofh,0,lengthof(lofh)))
88 modulepar integer lofhi2 := lengthof(substr(lofh,0,lengthof(lofh)/2))
89 modulepar integer lofhi3 := lengthof(lofh & lofh1)
90 modulepar integer lofhi4 := lengthof(lofh1 & lofh1)
91 modulepar integer lofhi5 := lengthof(substr(lofh1,0,lengthof(lofh1)))
92
93 testcase lengthof_hexstr() runs on PDTestComponent{
94
95 if ((lofhi == 2*lengthof(lofh))
96 and (lofhi == lengthof(lofh & lofh)))
97 {setverdict(pass);}
98 else {setverdict(fail);}
99 if ((lofhi1 == lengthof(lofh))
100 and (lofhi1 == lengthof(substr(lofh,0,lengthof(lofh)))))
101 {setverdict(pass);}
102 else {setverdict(fail);}
103 if ((lofhi2 == 5)
104 and (lofhi2 == lengthof(substr(lofh,0,lengthof(lofh)/2))))
105 {setverdict(pass);}
106 else {setverdict(fail);}
107 if ((lofhi3 == 10)
108 and (lofhi3 == lengthof(lofh & lofh1)))
109 {setverdict(pass);}
110 else {setverdict(fail);}
111 if ((lofhi4 == 0)
112 and (lofhi4 == lengthof(lofh1 & lofh1)))
113 {setverdict(pass);}
114 else {setverdict(fail);}
115 if ((lofhi5 == 0)
116 and (lofhi5 == lengthof(substr(lofh1,0,lengthof(lofh1)))))
117 {setverdict(pass);}
118 else {setverdict(fail);}
119
120 var integer j;
121 var hexstring hh,h := ''H;
122
123 for (j:=0; j<lengthof(lofh); j:=j+1) {
124 h := h & lofh
125 if (lengthof(h) == (j+1)*lengthof(lofh))
126 {setverdict(pass);}
127 else {setverdict(fail);}
128 }
129
130 for (j:=lengthof(h); j>=0; j:=j-1) {
131 hh := substr(h,0,j)
132 if (lengthof(hh) == j)
133 {setverdict(pass);}
134 else {setverdict(fail);}
135 }
136
137 h := ''H
138 for (j:=1; j<4096; j:=j+1) {
139 h := h & int2hex(j,12)
140 if (lengthof(h) == j*12)
141 {setverdict(pass);}
142 else {setverdict(fail);}
143 hh :=int2hex(j,j)
144 if (lengthof(hh) == j)
145 {setverdict(pass);}
146 else {setverdict(fail);}
147 }
148 }
149
150 /*--- LENGTH OF OCTETSTRING --------------------------------------------------*/
151
152 const octetstring lofo := '11111100000011110000'O
153 const octetstring lofo1 := ''O
154
155 modulepar integer lofoi := lengthof(lofo & lofo)
156 modulepar integer lofoi1 := lengthof(substr(lofo,0,lengthof(lofo)))
157 modulepar integer lofoi2 := lengthof(substr(lofo,0,lengthof(lofo)/2))
158 modulepar integer lofoi3 := lengthof(lofo & lofo1)
159 modulepar integer lofoi4 := lengthof(lofo1 & lofo1)
160 modulepar integer lofoi5 := lengthof(substr(lofo1,0,lengthof(lofo1)))
161
162 testcase lengthof_octetstr() runs on PDTestComponent{
163
164 if ((lofoi == 2*lengthof(lofo))
165 and (lofoi == lengthof(lofo & lofo)))
166 {setverdict(pass);}
167 else {setverdict(fail);}
168 if ((lofoi1 == lengthof(lofo))
169 and (lofoi1 == lengthof(substr(lofo,0,lengthof(lofo)))))
170 {setverdict(pass);}
171 else {setverdict(fail);}
172 if ((lofoi2 == 5)
173 and (lofoi2 == lengthof(substr(lofo,0,lengthof(lofo)/2))))
174 {setverdict(pass);}
175 else {setverdict(fail);}
176 if ((lofoi3 == 10)
177 and (lofoi3 == lengthof(lofo & lofo1)))
178 {setverdict(pass);}
179 else {setverdict(fail);}
180 if ((lofoi4 == 0)
181 and (lofoi4 == lengthof(lofo1 & lofo1)))
182 {setverdict(pass);}
183 else {setverdict(fail);}
184 if ((lofoi5 == 0)
185 and (lofoi5 == lengthof(substr(lofo1,0,lengthof(lofo1)))))
186 {setverdict(pass);}
187 else {setverdict(fail);}
188
189 var integer j;
190 var octetstring oo,o := ''O;
191
192 for (j:=0; j<lengthof(lofo); j:=j+1) {
193 o := o & lofo
194 if (lengthof(o) == (j+1)*lengthof(lofo))
195 {setverdict(pass);}
196 else {setverdict(fail);}
197 }
198
199 for (j:=lengthof(o); j>=0; j:=j-1) {
200 oo := substr(o,0,j)
201 if (lengthof(oo) == j)
202 {setverdict(pass);}
203 else {setverdict(fail);}
204 }
205
206 o := ''O
207 for (j:=1; j<4096; j:=j+1) {
208 o := o & int2oct(j,12)
209 if (lengthof(o) == j*12)
210 {setverdict(pass);}
211 else {setverdict(fail);}
212 oo :=int2oct(j,j)
213 if (lengthof(oo) == j)
214 {setverdict(pass);}
215 else {setverdict(fail);}
216 }
217 }
218
219
220 /*--- LENGTH OF CHARSTRING --------------------------------------------------*/
221
222 const charstring lofc := "1110001100"
223 const charstring lofc1 := ""
224
225 modulepar integer lofci := lengthof(lofc & lofc)
226 modulepar integer lofci1 := lengthof(substr(lofc,0,lengthof(lofc)))
227 modulepar integer lofci2 := lengthof(substr(lofc,0,lengthof(lofc)/2))
228 modulepar integer lofci3 := lengthof(lofc & lofc1)
229 modulepar integer lofci4 := lengthof(lofc1 & lofc1)
230 modulepar integer lofci5 := lengthof(substr(lofc1,0,lengthof(lofc1)))
231
232 testcase lengthof_charstr() runs on PDTestComponent{
233
234 if ((lofci == 2*lengthof(lofc))
235 and (lofci == lengthof(lofc & lofc)))
236 {setverdict(pass);}
237 else {setverdict(fail);}
238 if ((lofci1 == lengthof(lofc))
239 and (lofci1 == lengthof(substr(lofc,0,lengthof(lofc)))))
240 {setverdict(pass);}
241 else {setverdict(fail);}
242 if ((lofci2 == 5)
243 and (lofci2 == lengthof(substr(lofc,0,lengthof(lofc)/2))))
244 {setverdict(pass);}
245 else {setverdict(fail);}
246 if ((lofci3 == 10)
247 and (lofci3 == lengthof(lofc & lofc1)))
248 {setverdict(pass);}
249 else {setverdict(fail);}
250 if ((lofci4 == 0)
251 and (lofci4 == lengthof(lofc1 & lofc1)))
252 {setverdict(pass);}
253 else {setverdict(fail);}
254 if ((lofci5 == 0)
255 and (lofci5 == lengthof(substr(lofc1,0,lengthof(lofc1)))))
256 {setverdict(pass);}
257 else {setverdict(fail);}
258
259 var integer j;
260 var charstring cc,c := "";
261
262 for (j:=0; j<lengthof(lofc); j:=j+1) {
263 c := c & lofc
264 if (lengthof(c) == (j+1)*lengthof(lofc))
265 {setverdict(pass);}
266 else {setverdict(fail);}
267 }
268
269 for (j:=lengthof(c); j>=0; j:=j-1) {
270 cc := substr(c,0,j)
271 if (lengthof(cc) == j)
272 {setverdict(pass);}
273 else {setverdict(fail);}
274 }
275
276 c := ""
277 for (j:=1; j<128; j:=j+1) {
278 c := c & int2char(j)
279 if (lengthof(c) == j)
280 {setverdict(pass);}
281 else {setverdict(fail);}
282 }
283 }
284
285
286 /*--- LENGTH OF UNIVERSAL CHARSTRING --------------------------------------------------*/
287
288 const universal charstring lofuc := "1111" & char(0,0,0,65) & "0000" & char(0,0,0,66)
289 const universal charstring lofuc1 := ""
290
291 modulepar integer lofuci := lengthof(lofuc & lofuc)
292 modulepar integer lofuci1 := lengthof(substr(lofuc,0,lengthof(lofuc)))
293 modulepar integer lofuci2 := lengthof(substr(lofuc,0,lengthof(lofuc)/2))
294 modulepar integer lofuci3 := lengthof(lofuc & lofuc1)
295 modulepar integer lofuci4 := lengthof(lofuc1 & lofuc1)
296 modulepar integer lofuci5 := lengthof(substr(lofuc1,0,lengthof(lofuc1)))
297
298 testcase lengthof_ucharstr() runs on PDTestComponent{
299
300 if ((lofuci == 2*lengthof(lofuc))
301 and (lofuci == lengthof(lofuc & lofuc)))
302 {setverdict(pass);}
303 else {setverdict(fail);}
304 if ((lofuci1 == lengthof(lofuc))
305 and (lofuci1 == lengthof(substr(lofuc,0,lengthof(lofuc)))))
306 {setverdict(pass);}
307 else {setverdict(fail);}
308 if ((lofuci2 == 5)
309 and (lofuci2 == lengthof(substr(lofuc,0,lengthof(lofuc)/2))))
310 {setverdict(pass);}
311 else {setverdict(fail);}
312 if ((lofuci3 == 10)
313 and (lofuci3 == lengthof(lofuc & lofuc1)))
314 {setverdict(pass);}
315 else {setverdict(fail);}
316 if ((lofuci4 == 0)
317 and (lofuci4 == lengthof(lofuc1 & lofuc1)))
318 {setverdict(pass);}
319 else {setverdict(fail);}
320 if ((lofuci5 == 0)
321 and (lofuci5 == lengthof(substr(lofuc1,0,lengthof(lofuc1)))))
322 {setverdict(pass);}
323 else {setverdict(fail);}
324
325 var integer j;
326 var universal charstring c,cc := "";
327
328 c := ""
329 for (j:=0; j<lengthof(lofuc); j:=j+1) {
330 c := c & lofuc
331 if (lengthof(c) == (j+1)*lengthof(lofc))
332 {setverdict(pass);}
333 else {setverdict(fail);}
334 }
335
336 for (j:=lengthof(c); j>=0; j:=j-1) {
337 cc := substr(c,0,j)
338 if (lengthof(cc) == j)
339 {setverdict(pass);}
340 else {setverdict(fail);}
341 }
342
343 c := ""
344 for (j:=1; j<128; j:=j+1) {
345 c := c & int2char(j)
346
347 if (lengthof(c) == j)
348 {setverdict(pass);}
349 else {setverdict(fail);}
350 }
351
352 }
353
354 control {
355 execute (lengthof_bitstr());
356 execute (lengthof_hexstr());
357 execute (lengthof_octetstr());
358 execute (lengthof_charstr());
359 execute (lengthof_ucharstr());
360 }
361
362 }
This page took 0.038945 seconds and 5 git commands to generate.