Sync with 5.1.0
[deliverable/titan.core.git] / regression_test / predefFunction / bit_to_SW.ttcn
CommitLineData
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 ******************************************************************************/
8module bit_to_SW { //^In TTCN-3 module `bit_to_SW'://
9
10type component PDTestComponent {};
11
12/*--- BIT2HEX --------------------------------------------------*/
13
14const hexstring b2hcon := bit2hex(''B)
15const hexstring b2hcon1 := bit2hex('000000000000'B & ''B & '111111111111'B)
16const hexstring b2hcon2 := bit2hex(substr('000000000000111111111111'B,0,12) & ''B & substr('000000000000111111111111'B,12,12))
17const hexstring b2hcon3 := bit2hex(('000000000000'B <@ 13) & ''B & ('111111111111'B @> 13))
18const hexstring b2hcon4 := bit2hex((not4b '111111111111'B) & '111111111111'B)
19const hexstring b2hcon5 := bit2hex('000000000000111111111111'B and4b '000000000000111111111111'B)
20const hexstring b2hcon6 := bit2hex('000000000000000000000000'B or4b '000000000000111111111111'B)
21const hexstring b2hcon7 := bit2hex('000000000000000000000000'B xor4b '000000000000111111111111'B)
22const hexstring b2hcon8 := bit2hex('10011'B)
23const hexstring b2hcon9 := bit2hex('11'B)
24
25const hexstring b2hconh := '000FFF'H
26
27testcase bit_to_hex() runs on PDTestComponent{ //^In testcase definition//
28
29 if ((b2hcon == bit2hex(''B))
30 and (b2hcon == ''H))
31 {setverdict(pass);}
32 else {setverdict(fail);} //^In else statement// \
33 //^warning: Control never reaches this code because of previous effective condition\(s\)//
34
35 if ((b2hcon1 == bit2hex('000000000000'B & ''B & '111111111111'B))
36 and (b2hcon1 == b2hconh))
37 {setverdict(pass);}
38 else {setverdict(fail);} //^In else statement// \
39 //^warning: Control never reaches this code because of previous effective condition\(s\)//
40
41 if ((b2hcon2 == bit2hex(substr('000000000000111111111111'B,0,12) & ''B & substr('000000000000111111111111'B,12,12)))
42 and (b2hcon2 == b2hconh))
43 {setverdict(pass);}
44 else {setverdict(fail);} //^In else statement// \
45 //^warning: Control never reaches this code because of previous effective condition\(s\)//
46
47 if ((b2hcon3 == bit2hex(('000000000000'B <@ 13) & ''B & ('111111111111'B @> 13)))
48 and (b2hcon3 == b2hconh))
49 {setverdict(pass);}
50 else {setverdict(fail);} //^In else statement// \
51 //^warning: Control never reaches this code because of previous effective condition\(s\)//
52
53 if ((b2hcon4 == bit2hex((not4b '111111111111'B) & '111111111111'B))
54 and (b2hcon4 == b2hconh))
55 {setverdict(pass);}
56 else {setverdict(fail);} //^In else statement// \
57 //^warning: Control never reaches this code because of previous effective condition\(s\)//
58
59 if ((b2hcon5 == bit2hex('000000000000111111111111'B and4b '000000000000111111111111'B))
60 and (b2hcon5 == b2hconh))
61 {setverdict(pass);}
62 else {setverdict(fail);} //^In else statement// \
63 //^warning: Control never reaches this code because of previous effective condition\(s\)//
64
65 if ((b2hcon6 == bit2hex('000000000000000000000000'B or4b '000000000000111111111111'B))
66 and (b2hcon6 == b2hconh))
67 {setverdict(pass);}
68 else {setverdict(fail);} //^In else statement// \
69 //^warning: Control never reaches this code because of previous effective condition\(s\)//
70
71 if ((b2hcon7 == bit2hex('000000000000000000000000'B xor4b '000000000000111111111111'B))
72 and (b2hcon7 == b2hconh))
73 {setverdict(pass);}
74 else {setverdict(fail);} //^In else statement// \
75 //^warning: Control never reaches this code because of previous effective condition\(s\)//
76
77 if ((b2hcon8 == bit2hex('10011'B))
78 and (b2hcon8 == '13'H))
79 {setverdict(pass);}
80 else {setverdict(fail);} //^In else statement// \
81 //^warning: Control never reaches this code because of previous effective condition\(s\)//
82
83 if ((b2hcon9 == bit2hex('11'B))
84 and (b2hcon9 == '3'H))
85 {setverdict(pass);}
86 else {setverdict(fail);} //^In else statement// \
87 //^warning: Control never reaches this code because of previous effective condition\(s\)//
88}
89
90/*--- BIT2INT --------------------------------------------------*/
91
92const integer b2icon := bit2int(''B)
93const integer b2icon1 := bit2int('111111'B & '111111'B)
94const integer b2icon2 := bit2int((not4b '111111'B) & '111111'B)
95const integer b2icon3 := bit2int(('111111'B and4b '000000'B) & '111111'B)
96const integer b2icon4 := bit2int(('000000'B or4b '000000'B) & '111111'B)
97const integer b2icon5 := bit2int(('000011'B xor4b '000011'B) & '111111'B)
98const integer i1 := 12345678910111213141516;
99const bitstring bs1 := '00000000000000000010100111010100001010110110010101101000100100110010100010111011111000001100'B;
100
101testcase bit_to_int() runs on PDTestComponent{ //^In testcase definition//
102
103 if ((b2icon == bit2int(''B))
104 and (b2icon == 0))
105 {setverdict(pass);}
106 else {setverdict(fail);} //^In else statement// \
107 //^warning: Control never reaches this code because of previous effective condition\(s\)//
108
109 if ((b2icon1 == bit2int('111111'B & '111111'B))
110 and (b2icon1 == 4095))
111 {setverdict(pass);}
112 else {setverdict(fail);} //^In else statement// \
113 //^warning: Control never reaches this code because of previous effective condition\(s\)//
114
115 if ((b2icon2 == bit2int((not4b '111111'B) & '111111'B))
116 and (b2icon2 == 63))
117 {setverdict(pass);}
118 else {setverdict(fail);} //^In else statement// \
119 //^warning: Control never reaches this code because of previous effective condition\(s\)//
120
121 if ((b2icon3 == bit2int(('111111'B and4b '000000'B) & '111111'B))
122 and (b2icon3 == 63))
123 {setverdict(pass);}
124 else {setverdict(fail);} //^In else statement// \
125 //^warning: Control never reaches this code because of previous effective condition\(s\)//
126
127 if ((b2icon4 == bit2int(('000000'B or4b '000000'B) & '111111'B))
128 and (b2icon4 == 63))
129 {setverdict(pass);}
130 else {setverdict(fail);} //^In else statement// \
131 //^warning: Control never reaches this code because of previous effective condition\(s\)//
132
133 if ((b2icon5 == bit2int(('000011'B xor4b '000011'B) & '111111'B))
134 and (b2icon5 == 63))
135 {setverdict(pass);}
136 else {setverdict(fail);} //^In else statement// \
137 //^warning: Control never reaches this code because of previous effective condition\(s\)//
138
139 if (bit2int(bs1) == 12345678910111213141516)
140 {setverdict(pass);}
141 else {setverdict(fail);} //^In else statement// \
142 //^warning: Control never reaches this code because of previous effective condition\(s\)//
143 if (bit2int('00000000000000000010100111010100001010110110010101101000100100110010100010111011111000001100'B) == 12345678910111213141516)
144 {setverdict(pass);}
145 else {setverdict(fail);} //^In else statement// \
146 //^warning: Control never reaches this code because of previous effective condition\(s\)//
147 if (bit2int(bs1) == 12345678910111213141516)
148 {setverdict(pass);}
149 else {setverdict(fail);} //^In else statement// \
150 //^warning: Control never reaches this code because of previous effective condition\(s\)//
151 if (bit2int(int2bit(bit2int('010100111010100001010110110010101101000100100110010100010111011111000001100'B), 75)) == 12345678910111213141516)
152 {setverdict(pass);}
153 else {setverdict(fail);} //^In else statement// \
154 //^warning: Control never reaches this code because of previous effective condition\(s\)//
155}
156
157/*--- BIT2OCT --------------------------------------------------*/
158
159const octetstring b2ocon := bit2oct(''B)
160const octetstring b2ocon1 := bit2oct('000000000000'B & ''B & '111111111111'B)
161const octetstring b2ocon2 := bit2oct(substr('000000000000111111111111'B,0,12) & ''B & substr('000000000000111111111111'B,12,12))
162const octetstring b2ocon3 := bit2oct(('000000000000'B <@ 13) & ''B & ('111111111111'B @> 13))
163const octetstring b2ocon4 := bit2oct((not4b '111111111111'B) & '111111111111'B)
164const octetstring b2ocon5 := bit2oct('000000000000111111111111'B and4b '000000000000111111111111'B)
165const octetstring b2ocon6 := bit2oct('000000000000000000000000'B or4b '000000000000111111111111'B)
166const octetstring b2ocon7 := bit2oct('000000000000000000000000'B xor4b '000000000000111111111111'B)
167const octetstring b2ocon8 := bit2oct('10011'B)
168const octetstring b2ocon9 := bit2oct('11'B)
169
170const octetstring b2ocono := '000FFF'O
171
172testcase bit_to_oct() runs on PDTestComponent{ //^In testcase definition//
173
174 if ((b2ocon == bit2oct(''B))
175 and (b2ocon == ''O))
176 {setverdict(pass);}
177 else {setverdict(fail);} //^In else statement// \
178 //^warning: Control never reaches this code because of previous effective condition\(s\)//
179
180 if ((b2ocon1 == bit2oct('000000000000'B & ''B & '111111111111'B))
181 and (b2ocon1 == b2ocono))
182 {setverdict(pass);}
183 else {setverdict(fail);} //^In else statement// \
184 //^warning: Control never reaches this code because of previous effective condition\(s\)//
185
186 if ((b2ocon2 == bit2oct(substr('000000000000111111111111'B,0,12) & ''B & substr('000000000000111111111111'B,12,12)))
187 and (b2ocon2 == b2ocono))
188 {setverdict(pass);}
189 else {setverdict(fail);} //^In else statement// \
190 //^warning: Control never reaches this code because of previous effective condition\(s\)//
191
192 if ((b2ocon3 == bit2oct(('000000000000'B <@ 13) & ''B & ('111111111111'B @> 13)))
193 and (b2ocon3 == b2ocono))
194 {setverdict(pass);}
195 else {setverdict(fail);} //^In else statement// \
196 //^warning: Control never reaches this code because of previous effective condition\(s\)//
197
198 if ((b2ocon4 == bit2oct((not4b '111111111111'B) & '111111111111'B))
199 and (b2ocon4 == b2ocono))
200 {setverdict(pass);}
201 else {setverdict(fail);} //^In else statement// \
202 //^warning: Control never reaches this code because of previous effective condition\(s\)//
203
204 if ((b2ocon5 == bit2oct('000000000000111111111111'B and4b '000000000000111111111111'B))
205 and (b2ocon5 == b2ocono))
206 {setverdict(pass);}
207 else {setverdict(fail);} //^In else statement// \
208 //^warning: Control never reaches this code because of previous effective condition\(s\)//
209
210 if ((b2ocon6 == bit2oct('000000000000000000000000'B or4b '000000000000111111111111'B))
211 and (b2ocon6 == b2ocono))
212 {setverdict(pass);}
213 else {setverdict(fail);} //^In else statement// \
214 //^warning: Control never reaches this code because of previous effective condition\(s\)//
215
216 if ((b2ocon7 == bit2oct('000000000000000000000000'B xor4b '000000000000111111111111'B))
217 and (b2ocon7 == b2ocono))
218 {setverdict(pass);}
219 else {setverdict(fail);} //^In else statement// \
220 //^warning: Control never reaches this code because of previous effective condition\(s\)//
221
222 if ((b2ocon8 == bit2oct('10011'B))
223 and (b2ocon8 == '13'O))
224 {setverdict(pass);}
225 else {setverdict(fail);} //^In else statement// \
226 //^warning: Control never reaches this code because of previous effective condition\(s\)//
227
228 if ((b2ocon9 == bit2oct('11'B))
229 and (b2ocon9 == '03'O))
230 {setverdict(pass);}
231 else {setverdict(fail);} //^In else statement// \
232 //^warning: Control never reaches this code because of previous effective condition\(s\)//
233}
234
235/*--- BIT2STR --------------------------------------------------*/
236
237const charstring b2scon := bit2str(''B)
238const charstring b2scon1 := bit2str('000000'B & ''B & '111111'B)
239const charstring b2scon2 := bit2str(substr('000000111111'B,0,6) & ''B & substr('000000111111'B,6,6))
240const charstring b2scon3 := bit2str(('000000'B <@ 3) & ''B & ('111111'B @> 3))
241const charstring b2scon4 := bit2str((not4b '111111'B) & '111111'B)
242const charstring b2scon5 := bit2str('000000111111'B and4b '000000111111'B)
243const charstring b2scon6 := bit2str('000000000000'B or4b '000000111111'B)
244const charstring b2scon7 := bit2str('000000000000'B xor4b '000000111111'B)
245
246const charstring b2scons := "000000111111"
247
248testcase bit_to_str() runs on PDTestComponent{ //^In testcase definition//
249
250 if ((b2scon == bit2str(''B))
251 and (b2scon == ""))
252 {setverdict(pass);}
253 else {setverdict(fail);} //^In else statement// \
254 //^warning: Control never reaches this code because of previous effective condition\(s\)//
255
256 if ((b2scon1 == bit2str('000000'B & ''B & '111111'B))
257 and (b2scon1 == b2scons))
258 {setverdict(pass);}
259 else {setverdict(fail);} //^In else statement// \
260 //^warning: Control never reaches this code because of previous effective condition\(s\)//
261
262 if ((b2scon2 == bit2str(substr('000000111111'B,0,6) & ''B & substr('000000111111'B,6,6)))
263 and (b2scon2 == b2scons))
264 {setverdict(pass);}
265 else {setverdict(fail);} //^In else statement// \
266 //^warning: Control never reaches this code because of previous effective condition\(s\)//
267
268 if ((b2scon3 == bit2str(('000000'B <@ 3) & ''B & ('111111'B @> 3)))
269 and (b2scon3 == b2scons))
270 {setverdict(pass);}
271 else {setverdict(fail);} //^In else statement// \
272 //^warning: Control never reaches this code because of previous effective condition\(s\)//
273
274 if ((b2scon4 == bit2str((not4b '111111'B) & '111111'B))
275 and (b2scon4 == b2scons))
276 {setverdict(pass);}
277 else {setverdict(fail);} //^In else statement// \
278 //^warning: Control never reaches this code because of previous effective condition\(s\)//
279
280 if ((b2scon5 == bit2str('000000111111'B and4b '000000111111'B))
281 and (b2scon5 == b2scons))
282 {setverdict(pass);}
283 else {setverdict(fail);} //^In else statement// \
284 //^warning: Control never reaches this code because of previous effective condition\(s\)//
285
286 if ((b2scon6 == bit2str('000000000000'B or4b '000000111111'B))
287 and (b2scon6 == b2scons))
288 {setverdict(pass);}
289 else {setverdict(fail);} //^In else statement// \
290 //^warning: Control never reaches this code because of previous effective condition\(s\)//
291
292 if ((b2scon7 == bit2str('000000000000'B xor4b '000000111111'B))
293 and (b2scon7 == b2scons))
294 {setverdict(pass);}
295 else {setverdict(fail);} //^In else statement// \
296 //^warning: Control never reaches this code because of previous effective condition\(s\)//
297}
298
299control {
300 execute (bit_to_hex());
301 execute (bit_to_int());
302 execute (bit_to_oct());
303 execute (bit_to_str());
304}
305
306}
This page took 0.034106 seconds and 5 git commands to generate.