Sync with 5.4.0
[deliverable/titan.core.git] / regression_test / predefFunction / char_to_OK.ttcn
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 ******************************************************************************/
8 module char_to_OK {
9
10 type component PDTestComponent {};
11
12 /*--- CHAR2INT --------------------------------------------------*/
13
14 const charstring c2ipars := "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
15
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)
21
22
23 testcase char_to_int() runs on PDTestComponent{
24
25 if ((c2ipar1 == 65)
26 and (c2ipar1 == char2int("A")))
27 {setverdict(pass);}
28 else {setverdict(fail);}
29 if ((c2ipar2 == 10)
30 and (c2ipar2 == char2int("\n")))
31 {setverdict(pass);}
32 else {setverdict(fail);}
33 if ((c2ipar3 == 65)
34 and (c2ipar3 == char2int("" & "A" & "")))
35 {setverdict(pass);}
36 else {setverdict(fail);}
37 if ((c2ipar4 == 65)
38 and (c2ipar4 == char2int(substr(c2ipars,0,1))))
39 {setverdict(pass);}
40 else {setverdict(fail);}
41 if ((c2ipar5 == 65)
42 and (c2ipar5 == char2int("A" @> 1)))
43 {setverdict(pass);}
44 else {setverdict(fail);}
45
46 var integer j
47 for (j:=0; j<lengthof(c2ipars); j:=j+1) {
48 if (char2int(substr(c2ipars,j,1))-char2int("A") == j)
49 {setverdict(pass);}
50 else {setverdict(fail);}
51 }
52 }
53
54 /*--- UNICHAR2INT --------------------------------------------------*/
55
56 const universal charstring uc2ipars := char(0,0,0,65) & "BCDEFGHIJKLMNOPQRSTUVWXYZ"
57
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))
66
67
68 testcase unichar_to_int() runs on PDTestComponent{
69
70 if ((uc2ipar1 == 65)
71 and (uc2ipar1 == unichar2int("A")))
72 {setverdict(pass);}
73 else {setverdict(fail);}
74 if ((uc2ipar2 == 65)
75 and (uc2ipar2 == unichar2int(char(0,0,0,65))))
76 {setverdict(pass);}
77 else {setverdict(fail);}
78 if ((uc2ipar3 == 65)
79 and (uc2ipar3 == unichar2int("" & char(0,0,0,65) & "")))
80 {setverdict(pass);}
81 else {setverdict(fail);}
82 if ((uc2ipar4 == 65)
83 and (uc2ipar4 == unichar2int(substr(uc2ipars,0,1))))
84 {setverdict(pass);}
85 else {setverdict(fail);}
86 if ((uc2ipar5 == 255)
87 and (uc2ipar5 == unichar2int(char(0,0,0,255))))
88 {setverdict(pass);}
89 else {setverdict(fail);}
90 if ((uc2ipar6 == 65535)
91 and (uc2ipar6 == unichar2int(char(0,0,255,255))))
92 {setverdict(pass);}
93 else {setverdict(fail);}
94 if ((uc2ipar7 == 16777215)
95 and (uc2ipar7 == unichar2int(char(0,255,255,255))))
96 {setverdict(pass);}
97 else {setverdict(fail);}
98 if ((uc2ipar8 == 2147483647)
99 and (uc2ipar8 == unichar2int(char(127,255,255,255))))
100 {setverdict(pass);}
101 else {setverdict(fail);}
102 }
103
104 /*--- CHAR2OCT --------------------------------------------------*/
105
106 const charstring c2opars := "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
107
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)
113
114 testcase char_to_oct() runs on PDTestComponent{
115
116 if ((c2opar1 == '41'O)
117 and (c2opar1 == char2oct("A")))
118 {setverdict(pass);}
119 else {setverdict(fail);}
120 if ((c2opar2 == '0A'O)
121 and (c2opar2 == char2oct("\n")))
122 {setverdict(pass);}
123 else {setverdict(fail);}
124 if ((c2opar3 == '41'O)
125 and (c2opar3 == char2oct("" & "A" & "")))
126 {setverdict(pass);}
127 else {setverdict(fail);}
128 if ((c2opar4 == '41'O)
129 and (c2opar4 == char2oct(substr(c2ipars,0,1))))
130 {setverdict(pass);}
131 else {setverdict(fail);}
132 if ((c2opar5 == '41'O)
133 and (c2opar5 == char2oct("A" @> 1)))
134 {setverdict(pass);}
135 else {setverdict(fail);}
136
137 var integer j
138 for (j:=0; j<lengthof(c2opars); j:=j+1) {
139 if (oct2int(char2oct(substr(c2opars,j,1)))-65 == j)
140 {setverdict(pass);}
141 else {setverdict(fail);}
142 }
143 }
144
145 control {
146 execute (char_to_int());
147 execute (unichar_to_int());
148 execute (char_to_oct());
149 }
150
151 }
This page took 0.035009 seconds and 5 git commands to generate.