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 /*--- HEX2BIT --------------------------------------------------*/
14 modulepar bitstring h2bpar := hex2bit(''H)
15 modulepar bitstring h2bpar1 := hex2bit('000000'H & ''H & '111111'H)
16 modulepar bitstring h2bpar2 := hex2bit(substr('000000111111'H,0,6) & ''H & substr('000000111111'H,6,6))
17 const bitstring h2bcon2 := hex2bit(substr('000000111111'H,0,6) & ''H & substr('000000111111'H,6,6))
18 modulepar bitstring h2bpar3 := hex2bit(('000000'H <@ lengthof(h2bcon2)/2) & ''H & ('111111'H @> lengthof(h2bcon2)/2))
19 modulepar bitstring h2bpar4 := hex2bit((not4b 'FFFFFF'H) & '111111'H)
20 modulepar bitstring h2bpar5 := hex2bit('000000111111'H and4b '000000111111'H)
21 modulepar bitstring h2bpar6 := hex2bit('000000000000'H or4b '000000111111'H)
22 modulepar bitstring h2bpar7 := hex2bit('000000000000'H xor4b '000000111111'H)
24 const bitstring h2bparb := '000000000000000000000000000100010001000100010001'B
26 testcase hex_to_bit() runs on PDTestComponent{
28 if ((h2bpar == hex2bit(''H))
31 else {setverdict(fail);}
33 if ((h2bpar1 == hex2bit('000000'H & ''H & '111111'H))
34 and (h2bpar1 == h2bparb))
36 else {setverdict(fail);}
38 if ((h2bpar2 == hex2bit(substr('000000111111'H,0,6) & ''H & substr('000000111111'H,6,6)))
39 and (h2bpar2 == h2bparb))
41 else {setverdict(fail);}
43 if ((h2bpar3 == hex2bit(('000000'H <@ lengthof(h2bpar2)/2) & ''H & ('111111'H @> lengthof(h2bpar2)/2)))
44 and (h2bpar3 == h2bparb))
46 else {setverdict(fail);}
48 if ((h2bpar4 == hex2bit((not4b 'FFFFFF'H) & '111111'H))
49 and (h2bpar4 == h2bparb))
51 else {setverdict(fail);}
53 if ((h2bpar5 == hex2bit('000000111111'H and4b '000000111111'H))
54 and (h2bpar5 == h2bparb))
56 else {setverdict(fail);}
58 if ((h2bpar6 == hex2bit('000000000000'H or4b '000000111111'H))
59 and (h2bpar6 == h2bparb))
61 else {setverdict(fail);}
63 if ((h2bpar7 == hex2bit('000000000000'H xor4b '000000111111'H))
64 and (h2bpar7 == h2bparb))
66 else {setverdict(fail);}
69 /*--- HEX2INT --------------------------------------------------*/
71 modulepar integer h2ipar := hex2int(''H)
72 modulepar integer h2ipar1 := hex2int('FFF'H & 'FFFF'H)
73 modulepar integer h2ipar2 := hex2int((not4b 'FFF'H) & 'FFFF'H)
74 modulepar integer h2ipar3 := hex2int(('FFF'H and4b '000'H) & 'FFFF'H)
75 modulepar integer h2ipar4 := hex2int(('000'H or4b '000'H) & 'FFFF'H)
76 modulepar integer h2ipar5 := hex2int(('0FF'H xor4b '0FF'H) & 'FFFF'H)
77 modulepar integer h2i1_16 := 12345678910111213141516;
79 testcase hex_to_int() runs on PDTestComponent{
80 var integer i1 := 12345678910111213141516
81 var hexstring hs1 := '000000000000029D42B65689328BBE0C'H
84 if ((h2ipar == hex2int(''H))
87 else {setverdict(fail);}
89 if ((h2ipar1 == hex2int('FFF'H & 'FFFF'H))
90 and (h2ipar1 == 268435455))
92 else {setverdict(fail);}
94 b := hex2int((not4b 'FFF'H) & 'FFFF'H)
96 and (h2ipar2 == 65535))
98 else {setverdict(fail);}
100 b := hex2int(('FFF'H and4b '000'H) & 'FFFF'H)
102 and (h2ipar3 == 65535))
104 else {setverdict(fail);}
106 b := hex2int(('000'H or4b '000'H) & 'FFFF'H)
108 and (h2ipar4 == 65535))
110 else {setverdict(fail);}
112 b := hex2int(('0FF'H xor4b '0FF'H) & 'FFFF'H)
114 and (h2ipar5 == 65535))
116 else {setverdict(fail);}
118 if (hex2int(hs1) == i1)
120 else {setverdict(fail);}
121 if (hex2int('000000000000029D42B65689328BBE0C'H) == h2i1_16)
123 else {setverdict(fail);}
124 if (hex2int(hs1) == 12345678910111213141516)
126 else {setverdict(fail);}
127 if (hex2int('029D42B65689328BBE0C'H) == h2i1_16)
129 else {setverdict(fail);}
132 for (j:=0; j<4096; j:=j+1) {
133 if (hex2int(int2hex(j,3)) == j)
135 else {setverdict(fail);}
140 /*--- HEX2OCT --------------------------------------------------*/
142 modulepar octetstring h2opar := hex2oct(''H)
143 modulepar octetstring h2opar1 := hex2oct('000000'H & ''H & '111111'H)
144 modulepar octetstring h2opar2 := hex2oct(substr('000000111111'H,0,6) & ''H & substr('000000111111'H,6,6))
145 modulepar octetstring h2opar3 := hex2oct(('000000'H <@ 3) & ''H & ('111111'H @> 3))
146 modulepar octetstring h2opar4 := hex2oct((not4b 'FFFFFF'H) & '111111'H)
147 modulepar octetstring h2opar5 := hex2oct('000000111111'H and4b '000000111111'H)
148 modulepar octetstring h2opar6 := hex2oct('000000000000'H or4b '000000111111'H)
149 modulepar octetstring h2opar7 := hex2oct('000000000000'H xor4b '000000111111'H)
150 modulepar octetstring h2opar8 := hex2oct('00011'H)
151 modulepar octetstring h2opar9 := hex2oct('1'H)
153 modulepar octetstring h2oparo := '000000111111'O
155 testcase hex_to_oct() runs on PDTestComponent{
157 if ((h2opar == hex2oct(''H))
160 else {setverdict(fail);}
162 if ((h2opar1 == hex2oct('000000'H & ''H & '111111'H))
163 and (h2opar1 == h2oparo))
165 else {setverdict(fail);}
167 if ((h2opar2 == hex2oct(substr('000000111111'H,0,6) & ''H & substr('000000111111'H,6,6)))
168 and (h2opar2 == h2oparo))
170 else {setverdict(fail);}
172 if ((h2opar3 == hex2oct(('000000'H <@ 3) & ''H & ('111111'H @> 3)))
173 and (h2opar3 == h2oparo))
175 else {setverdict(fail);}
177 if ((h2opar4 == hex2oct((not4b 'FFFFFF'H) & '111111'H))
178 and (h2opar4 == h2oparo))
180 else {setverdict(fail);}
182 if ((h2opar5 == hex2oct('000000111111'H and4b '000000111111'H))
183 and (h2opar5 == h2oparo))
185 else {setverdict(fail);}
187 if ((h2opar6 == hex2oct('000000000000'H or4b '000000111111'H))
188 and (h2opar6 == h2oparo))
190 else {setverdict(fail);}
192 if ((h2opar7 == hex2oct('000000000000'H xor4b '000000111111'H))
193 and (h2opar7 == h2oparo))
195 else {setverdict(fail);}
197 if ((h2opar8 == hex2oct('00011'H))
198 and (h2opar8 == '000011'O))
200 else {setverdict(fail);}
202 if ((h2opar9 == hex2oct('1'H))
203 and (h2opar9 == '01'O))
205 else {setverdict(fail);}
210 /*--- HEX2STR --------------------------------------------------*/
212 modulepar charstring h2spar := hex2str(''H)
213 modulepar charstring h2spar1 := hex2str('000000'H & ''H & '111111'H)
214 modulepar charstring h2spar2 := hex2str(substr('000000111111'H,0,6) & ''H & substr('000000111111'H,6,6))
215 modulepar charstring h2spar3 := hex2str(('000000'H <@ 3) & ''H & ('111111'H @> 3))
216 modulepar charstring h2spar4 := hex2str((not4b 'FFFFFF'H) & '111111'H)
217 modulepar charstring h2spar5 := hex2str('000000111111'H and4b '000000111111'H)
218 modulepar charstring h2spar6 := hex2str('000000000000'H or4b '000000111111'H)
219 modulepar charstring h2spar7 := hex2str('000000000000'H xor4b '000000111111'H)
221 modulepar charstring h2spars := "000000111111"
223 testcase hex_to_str() runs on PDTestComponent{
225 if ((h2spar == hex2str(''H))
228 else {setverdict(fail);}
230 if ((h2spar1 == hex2str('000000'H & ''H & '111111'H))
231 and (h2spar1 == h2spars))
233 else {setverdict(fail);}
235 if ((h2spar2 == hex2str(substr('000000111111'H,0,6) & ''H & substr('000000111111'H,6,6)))
236 and (h2spar2 == h2spars))
238 else {setverdict(fail);}
240 if ((h2spar3 == hex2str(('000000'H <@ 3) & ''H & ('111111'H @> 3)))
241 and (h2spar3 == h2spars))
243 else {setverdict(fail);}
245 if ((h2spar4 == hex2str((not4b 'FFFFFF'H) & '111111'H))
246 and (h2spar4 == h2spars))
248 else {setverdict(fail);}
250 if ((h2spar5 == hex2str('000000111111'H and4b '000000111111'H))
251 and (h2spar5 == h2spars))
253 else {setverdict(fail);}
255 if ((h2spar6 == hex2str('000000000000'H or4b '000000111111'H))
256 and (h2spar6 == h2spars))
258 else {setverdict(fail);}
260 if ((h2spar7 == hex2str('000000000000'H xor4b '000000111111'H))
261 and (h2spar7 == h2spars))
263 else {setverdict(fail);}
268 execute (hex_to_bit());
269 execute (hex_to_int());
270 execute (hex_to_oct());
271 execute (hex_to_str());