1 /******************************************************************************
2 * Copyright (c) 2000-2015 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 /*--- CHAR2INT --------------------------------------------------*/
14 const charstring c2ipars := "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
16 modulepar integer c2ipar1 := char2int("A")
17 modulepar integer c2ipar2 := char2int("\n")
18 modulepar integer c2ipar3 := char2int("" & "A" & "")
19 modulepar integer c2ipar4 := char2int(substr(c2ipars,0,1))
20 modulepar integer c2ipar5 := char2int("A" <@ 1)
23 testcase char_to_int() runs on PDTestComponent{
26 and (c2ipar1 == char2int("A")))
28 else {setverdict(fail);}
30 and (c2ipar2 == char2int("\n")))
32 else {setverdict(fail);}
34 and (c2ipar3 == char2int("" & "A" & "")))
36 else {setverdict(fail);}
38 and (c2ipar4 == char2int(substr(c2ipars,0,1))))
40 else {setverdict(fail);}
42 and (c2ipar5 == char2int("A" @> 1)))
44 else {setverdict(fail);}
47 for (j:=0; j<lengthof(c2ipars); j:=j+1) {
48 if (char2int(substr(c2ipars,j,1))-char2int("A") == j)
50 else {setverdict(fail);}
54 /*--- UNICHAR2INT --------------------------------------------------*/
56 const universal charstring uc2ipars := char(0,0,0,65) & "BCDEFGHIJKLMNOPQRSTUVWXYZ"
58 modulepar integer uc2ipar1 := unichar2int("A")
59 modulepar integer uc2ipar2 := unichar2int(char(0,0,0,65))
60 modulepar integer uc2ipar3 := unichar2int("" & char(0,0,0,65) & "")
61 modulepar integer uc2ipar4 := unichar2int(substr(uc2ipars,0,1))
62 modulepar integer uc2ipar5 := unichar2int(char(0,0,0,255))
63 modulepar integer uc2ipar6 := unichar2int(char(0,0,255,255))
64 modulepar integer uc2ipar7 := unichar2int(char(0,255,255,255))
65 modulepar integer uc2ipar8 := unichar2int(char(127,255,255,255))
68 testcase unichar_to_int() runs on PDTestComponent{
71 and (uc2ipar1 == unichar2int("A")))
73 else {setverdict(fail);}
75 and (uc2ipar2 == unichar2int(char(0,0,0,65))))
77 else {setverdict(fail);}
79 and (uc2ipar3 == unichar2int("" & char(0,0,0,65) & "")))
81 else {setverdict(fail);}
83 and (uc2ipar4 == unichar2int(substr(uc2ipars,0,1))))
85 else {setverdict(fail);}
87 and (uc2ipar5 == unichar2int(char(0,0,0,255))))
89 else {setverdict(fail);}
90 if ((uc2ipar6 == 65535)
91 and (uc2ipar6 == unichar2int(char(0,0,255,255))))
93 else {setverdict(fail);}
94 if ((uc2ipar7 == 16777215)
95 and (uc2ipar7 == unichar2int(char(0,255,255,255))))
97 else {setverdict(fail);}
98 if ((uc2ipar8 == 2147483647)
99 and (uc2ipar8 == unichar2int(char(127,255,255,255))))
101 else {setverdict(fail);}
104 /*--- CHAR2OCT --------------------------------------------------*/
106 const charstring c2opars := "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
108 modulepar octetstring c2opar1 := char2oct("A")
109 modulepar octetstring c2opar2 := char2oct("\n")
110 modulepar octetstring c2opar3 := char2oct("" & "A" & "")
111 modulepar octetstring c2opar4 := char2oct(substr(c2opars,0,1))
112 modulepar octetstring c2opar5 := char2oct("A" @> 1)
114 testcase char_to_oct() runs on PDTestComponent{
116 if ((c2opar1 == '41'O)
117 and (c2opar1 == char2oct("A")))
119 else {setverdict(fail);}
120 if ((c2opar2 == '0A'O)
121 and (c2opar2 == char2oct("\n")))
123 else {setverdict(fail);}
124 if ((c2opar3 == '41'O)
125 and (c2opar3 == char2oct("" & "A" & "")))
127 else {setverdict(fail);}
128 if ((c2opar4 == '41'O)
129 and (c2opar4 == char2oct(substr(c2ipars,0,1))))
131 else {setverdict(fail);}
132 if ((c2opar5 == '41'O)
133 and (c2opar5 == char2oct("A" @> 1)))
135 else {setverdict(fail);}
138 for (j:=0; j<lengthof(c2opars); j:=j+1) {
139 if (oct2int(char2oct(substr(c2opars,j,1)))-65 == j)
141 else {setverdict(fail);}
146 execute (char_to_int());
147 execute (unichar_to_int());
148 execute (char_to_oct());