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 ******************************************************************************/
10 type component PDTestComponent {};
12 /*--- LENGTH OF BITSTRING --------------------------------------------------*/
14 const bitstring lofb := '1110001100'B
15 const bitstring lofb1 := ''B
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)))
24 testcase lengthof_bitstr() runs on PDTestComponent{
26 if ((lofbi == 2*lengthof(lofb))
27 and (lofbi == lengthof(lofb & lofb)))
29 else {setverdict(fail);}
30 if ((lofbi1 == lengthof(lofb))
31 and (lofbi1 == lengthof(substr(lofb,0,lengthof(lofb)))))
33 else {setverdict(fail);}
35 and (lofbi2 == lengthof(substr(lofb,0,lengthof(lofb)/2))))
37 else {setverdict(fail);}
39 and (lofbi3 == lengthof(lofb & lofb1)))
41 else {setverdict(fail);}
43 and (lofbi4 == lengthof(lofb1 & lofb1)))
45 else {setverdict(fail);}
47 and (lofbi5 == lengthof(substr(lofb1,0,lengthof(lofb1)))))
49 else {setverdict(fail);}
52 var bitstring bb,b := ''B;
54 for (j:=0; j<lengthof(lofb); j:=j+1) {
56 if (lengthof(b) == (j+1)*lengthof(lofb))
58 else {setverdict(fail);}
61 for (j:=lengthof(b); j>=0; j:=j-1) {
63 if (lengthof(bb) == j)
65 else {setverdict(fail);}
69 for (j:=1; j<4096; j:=j+1) {
70 b := b & int2bit(j,12)
71 if (lengthof(b) == j*12)
73 else {setverdict(fail);}
75 if (lengthof(bb) == j)
77 else {setverdict(fail);}
81 /*--- LENGTH OF HEXSTRING --------------------------------------------------*/
83 const hexstring lofh := '1110001100'H
84 const hexstring lofh1 := ''H
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)))
93 testcase lengthof_hexstr() runs on PDTestComponent{
95 if ((lofhi == 2*lengthof(lofh))
96 and (lofhi == lengthof(lofh & lofh)))
98 else {setverdict(fail);}
99 if ((lofhi1 == lengthof(lofh))
100 and (lofhi1 == lengthof(substr(lofh,0,lengthof(lofh)))))
102 else {setverdict(fail);}
104 and (lofhi2 == lengthof(substr(lofh,0,lengthof(lofh)/2))))
106 else {setverdict(fail);}
108 and (lofhi3 == lengthof(lofh & lofh1)))
110 else {setverdict(fail);}
112 and (lofhi4 == lengthof(lofh1 & lofh1)))
114 else {setverdict(fail);}
116 and (lofhi5 == lengthof(substr(lofh1,0,lengthof(lofh1)))))
118 else {setverdict(fail);}
121 var hexstring hh,h := ''H;
123 for (j:=0; j<lengthof(lofh); j:=j+1) {
125 if (lengthof(h) == (j+1)*lengthof(lofh))
127 else {setverdict(fail);}
130 for (j:=lengthof(h); j>=0; j:=j-1) {
132 if (lengthof(hh) == j)
134 else {setverdict(fail);}
138 for (j:=1; j<4096; j:=j+1) {
139 h := h & int2hex(j,12)
140 if (lengthof(h) == j*12)
142 else {setverdict(fail);}
144 if (lengthof(hh) == j)
146 else {setverdict(fail);}
150 /*--- LENGTH OF OCTETSTRING --------------------------------------------------*/
152 const octetstring lofo := '11111100000011110000'O
153 const octetstring lofo1 := ''O
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)))
162 testcase lengthof_octetstr() runs on PDTestComponent{
164 if ((lofoi == 2*lengthof(lofo))
165 and (lofoi == lengthof(lofo & lofo)))
167 else {setverdict(fail);}
168 if ((lofoi1 == lengthof(lofo))
169 and (lofoi1 == lengthof(substr(lofo,0,lengthof(lofo)))))
171 else {setverdict(fail);}
173 and (lofoi2 == lengthof(substr(lofo,0,lengthof(lofo)/2))))
175 else {setverdict(fail);}
177 and (lofoi3 == lengthof(lofo & lofo1)))
179 else {setverdict(fail);}
181 and (lofoi4 == lengthof(lofo1 & lofo1)))
183 else {setverdict(fail);}
185 and (lofoi5 == lengthof(substr(lofo1,0,lengthof(lofo1)))))
187 else {setverdict(fail);}
190 var octetstring oo,o := ''O;
192 for (j:=0; j<lengthof(lofo); j:=j+1) {
194 if (lengthof(o) == (j+1)*lengthof(lofo))
196 else {setverdict(fail);}
199 for (j:=lengthof(o); j>=0; j:=j-1) {
201 if (lengthof(oo) == j)
203 else {setverdict(fail);}
207 for (j:=1; j<4096; j:=j+1) {
208 o := o & int2oct(j,12)
209 if (lengthof(o) == j*12)
211 else {setverdict(fail);}
213 if (lengthof(oo) == j)
215 else {setverdict(fail);}
220 /*--- LENGTH OF CHARSTRING --------------------------------------------------*/
222 const charstring lofc := "1110001100"
223 const charstring lofc1 := ""
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)))
232 testcase lengthof_charstr() runs on PDTestComponent{
234 if ((lofci == 2*lengthof(lofc))
235 and (lofci == lengthof(lofc & lofc)))
237 else {setverdict(fail);}
238 if ((lofci1 == lengthof(lofc))
239 and (lofci1 == lengthof(substr(lofc,0,lengthof(lofc)))))
241 else {setverdict(fail);}
243 and (lofci2 == lengthof(substr(lofc,0,lengthof(lofc)/2))))
245 else {setverdict(fail);}
247 and (lofci3 == lengthof(lofc & lofc1)))
249 else {setverdict(fail);}
251 and (lofci4 == lengthof(lofc1 & lofc1)))
253 else {setverdict(fail);}
255 and (lofci5 == lengthof(substr(lofc1,0,lengthof(lofc1)))))
257 else {setverdict(fail);}
260 var charstring cc,c := "";
262 for (j:=0; j<lengthof(lofc); j:=j+1) {
264 if (lengthof(c) == (j+1)*lengthof(lofc))
266 else {setverdict(fail);}
269 for (j:=lengthof(c); j>=0; j:=j-1) {
271 if (lengthof(cc) == j)
273 else {setverdict(fail);}
277 for (j:=1; j<128; j:=j+1) {
279 if (lengthof(c) == j)
281 else {setverdict(fail);}
286 /*--- LENGTH OF UNIVERSAL CHARSTRING --------------------------------------------------*/
288 const universal charstring lofuc := "1111" & char(0,0,0,65) & "0000" & char(0,0,0,66)
289 const universal charstring lofuc1 := ""
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)))
298 testcase lengthof_ucharstr() runs on PDTestComponent{
300 if ((lofuci == 2*lengthof(lofuc))
301 and (lofuci == lengthof(lofuc & lofuc)))
303 else {setverdict(fail);}
304 if ((lofuci1 == lengthof(lofuc))
305 and (lofuci1 == lengthof(substr(lofuc,0,lengthof(lofuc)))))
307 else {setverdict(fail);}
309 and (lofuci2 == lengthof(substr(lofuc,0,lengthof(lofuc)/2))))
311 else {setverdict(fail);}
313 and (lofuci3 == lengthof(lofuc & lofuc1)))
315 else {setverdict(fail);}
317 and (lofuci4 == lengthof(lofuc1 & lofuc1)))
319 else {setverdict(fail);}
321 and (lofuci5 == lengthof(substr(lofuc1,0,lengthof(lofuc1)))))
323 else {setverdict(fail);}
326 var universal charstring c,cc := "";
329 for (j:=0; j<lengthof(lofuc); j:=j+1) {
331 if (lengthof(c) == (j+1)*lengthof(lofc))
333 else {setverdict(fail);}
336 for (j:=lengthof(c); j>=0; j:=j-1) {
338 if (lengthof(cc) == j)
340 else {setverdict(fail);}
344 for (j:=1; j<128; j:=j+1) {
347 if (lengthof(c) == j)
349 else {setverdict(fail);}
355 execute (lengthof_bitstr());
356 execute (lengthof_hexstr());
357 execute (lengthof_octetstr());
358 execute (lengthof_charstr());
359 execute (lengthof_ucharstr());