Sync with 5.1.0
[deliverable/titan.core.git] / regression_test / ucharstrOper / external.cc
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 ///////////////////////////////////////////////////////////////////////////////
8 #include <TTCN3.hh>
9
10 namespace cstr__content {
11
12 void us_log(const UNIVERSAL_CHARSTRING& us) {
13 TTCN_Logger::begin_event(TTCN_USER);
14 us.log();
15 TTCN_Logger::end_event();
16 }
17
18 INTEGER tc__univ__char__cpp() {
19 const universal_char uc_array[] = {
20 { 0, 0, 1, 40 },
21 { 0, 0, 1, 41 },
22 { 0, 0, 1, 42 },
23 { 0, 0, 1, 43 }
24 };
25 UNIVERSAL_CHARSTRING us(1, 1, 1, 1);
26 universal_char uc = { 1, 1, 1, 1 };
27 if (us != uc || uc != us)
28 return __LINE__;
29 UNIVERSAL_CHARSTRING us2;
30 us2 = uc;
31 us_log(us2);
32 if (us2 != uc || uc != us2)
33 return __LINE__;
34 us = "a";
35 us_log(us);
36 if (us != "a" || "a" != us)
37 return __LINE__;
38 UNIVERSAL_CHARSTRING us3("abcd");
39 us_log(us3);
40 if (us3 != "abcd" || "abcd" != us3)
41 return __LINE__;
42 UNIVERSAL_CHARSTRING us4(uc);
43 us_log(us4);
44 if (us4 != uc || uc != us4)
45 return __LINE__;
46 UNIVERSAL_CHARSTRING us5(4, "abcd");
47 us_log(us5);
48 if (us5 != "abcd" || "abcd" != us5)
49 return __LINE__;
50 const universal_char* p_uc = static_cast<const universal_char*>(us5);
51 UNIVERSAL_CHARSTRING us_puc(4, p_uc);
52 us_log(us_puc);
53 universal_char uc_a = { 0, 0, 0, 97 };
54 if (us5[0] != uc_a || uc_a != us5[0] || us5[0] != "a" || "a" != us5[0])
55 return __LINE__;
56 us5[0] = "b";
57 us_log(us5);
58 if (us5[0] != "b" || "b" != us5[0] || us5[0] != us5[1] || us5 != "bbcd" || "bbcd" != us5)
59 return __LINE__;
60 us5[0] = uc_a;
61 us_log(us5);
62 if (us5[0] != "a" || "a" != us5[0] || us5 != "abcd" || "abcd" != us5)
63 return __LINE__;
64 CHARSTRING csx("x");
65 us5[0] = csx;
66 us_log(us5);
67 if (us5[0] != "x" || "x" != us5[0] || us5 != "xbcd" || "xbcd" != us5)
68 return __LINE__;
69 us5[0] = "a";
70 us5[0] = csx[0];
71 us_log(us5);
72 if (us5[0] != "x" || "x" != us5[0] || us5 != "xbcd" || "xbcd" != us5)
73 return __LINE__;
74 us5[0] = us2;
75 us_log(us5);
76 if (us5[0] != us2)
77 return __LINE__;
78 us5[0] = "a";
79 us5[0] = us2[0];
80 us_log(us5);
81 if (us5[0] != us2)
82 return __LINE__;
83
84 // UNIVERSAL_CHARSTRING_ELEMENT operator+ tests
85 universal_char uc_res[] = {
86 { 0, 0, 0, 97 },
87 { 0, 0, 0, 98 }
88 };
89 universal_char uc_res_abc[] = {
90 { 0, 0, 0, 97 },
91 { 0, 0, 0, 98 },
92 { 0, 0, 0, 99 }
93 };
94 universal_char uc_res_abX[] = {
95 { 0, 0, 0, 97 },
96 { 0, 0, 0, 98 },
97 { 1, 1, 1, 1 }
98 };
99 UNIVERSAL_CHARSTRING us_res_abc("abc");
100 UNIVERSAL_CHARSTRING us_res_abc_uni(3, uc_res_abc);
101 UNIVERSAL_CHARSTRING us_res_abX(3, uc_res_abX);
102 UNIVERSAL_CHARSTRING use1("ab");
103 UNIVERSAL_CHARSTRING use2(2, uc_res);
104 universal_char uc_b = { 0, 0, 0, 98 };
105 universal_char uc_c = { 0, 0, 0, 99 };
106 UNIVERSAL_CHARSTRING us_a(uc_a);
107 UNIVERSAL_CHARSTRING us_b(uc_b);
108 UNIVERSAL_CHARSTRING uce_res(2, uc_res);
109 CHARSTRING cse_res("ab");
110 CHARSTRING cs_a("a");
111 CHARSTRING cs_b("b");
112 UNIVERSAL_CHARSTRING use;
113 use = use1[0] + "b";
114 us_log(use);
115 if (use != "ab" || "ab" != use || use != uce_res || uce_res != use || use != cse_res || cse_res != use)
116 return __LINE__;
117 use = "a" + use1[1];
118 us_log(use);
119 if (use != "ab" || "ab" != use || use != uce_res || uce_res != use || use != cse_res || cse_res != use)
120 return __LINE__;
121 use = use2[0] + "b";
122 us_log(use);
123 if (use != "ab" || "ab" != use || use != uce_res || uce_res != use || use != cse_res || cse_res != use)
124 return __LINE__;
125 use = "a" + use2[1];
126 us_log(use);
127 if (use != "ab" || "ab" != use || use != uce_res || uce_res != use || use != cse_res || cse_res != use)
128 return __LINE__;
129 use = use1[0] + uc_b;
130 us_log(use);
131 if (use != "ab" || "ab" != use || use != uce_res || uce_res != use || use != cse_res || cse_res != use)
132 return __LINE__;
133 use = uc_a + use1[1];
134 us_log(use);
135 if (use != "ab" || "ab" != use || use != uce_res || uce_res != use || use != cse_res || cse_res != use)
136 return __LINE__;
137 use = use2[0] + uc_b;
138 us_log(use);
139 if (use != "ab" || "ab" != use || use != uce_res || uce_res != use || use != cse_res || cse_res != use)
140 return __LINE__;
141 use = uc_a + use2[1];
142 us_log(use);
143 if (use != "ab" || "ab" != use || use != uce_res || uce_res != use || use != cse_res || cse_res != use)
144 return __LINE__;
145 use = use1[0] + us_b;
146 us_log(use);
147 if (use != "ab" || "ab" != use || use != uce_res || uce_res != use || use != cse_res || cse_res != use)
148 return __LINE__;
149 use = us_a + use1[1];
150 us_log(use);
151 if (use != "ab" || "ab" != use || use != uce_res || uce_res != use || use != cse_res || cse_res != use)
152 return __LINE__;
153 use = use2[0] + us_b;
154 us_log(use);
155 if (use != "ab" || "ab" != use || use != uce_res || uce_res != use || use != cse_res || cse_res != use)
156 return __LINE__;
157 use = us_a + use2[1];
158 us_log(use);
159 if (use != "ab" || "ab" != use || use != uce_res || uce_res != use || use != cse_res || cse_res != use)
160 return __LINE__;
161 use = use1[0] + cs_b;
162 us_log(use);
163 if (use != "ab" || "ab" != use || use != uce_res || uce_res != use || use != cse_res || cse_res != use)
164 return __LINE__;
165 use = cs_a + use1[1];
166 us_log(use);
167 if (use != "ab" || "ab" != use || use != uce_res || uce_res != use || use != cse_res || cse_res != use)
168 return __LINE__;
169 use = use2[0] + cs_b;
170 us_log(use);
171 if (use != "ab" || "ab" != use || use != uce_res || uce_res != use || use != cse_res || cse_res != use)
172 return __LINE__;
173 use = cs_a + use2[1];
174 us_log(use);
175 if (use != "ab" || "ab" != use || use != uce_res || uce_res != use || use != cse_res || cse_res != use)
176 return __LINE__;
177 use = use1[0] + us_b;
178 us_log(use);
179 if (use != "ab" || "ab" != use || use != uce_res || uce_res != use || use != cse_res || cse_res != use)
180 return __LINE__;
181 use = us_a + use1[1];
182 us_log(use);
183 if (use != "ab" || "ab" != use || use != uce_res || uce_res != use || use != cse_res || cse_res != use)
184 return __LINE__;
185 use = use2[0] + us_b;
186 us_log(use);
187 if (use != "ab" || "ab" != use || use != uce_res || uce_res != use || use != cse_res || cse_res != use)
188 return __LINE__;
189 use = us_a + use2[1];
190 us_log(use);
191 if (use != "ab" || "ab" != use || use != uce_res || uce_res != use || use != cse_res || cse_res != use)
192 return __LINE__;
193 use = use1[0] + use1[1];
194 us_log(use);
195 if (use != "ab" || "ab" != use || use != uce_res || uce_res != use || use != cse_res || cse_res != use)
196 return __LINE__;
197 use = use2[0] + use2[1];
198 us_log(use);
199 if (use != "ab" || "ab" != use || use != uce_res || uce_res != use || use != cse_res || cse_res != use)
200 return __LINE__;
201 use = use1[0] + use2[1];
202 us_log(use);
203 if (use != "ab" || "ab" != use || use != uce_res || uce_res != use || use != cse_res || cse_res != use)
204 return __LINE__;
205 use = use2[0] + use1[1];
206 us_log(use);
207 if (use != "ab" || "ab" != use || use != uce_res || uce_res != use || use != cse_res || cse_res != use)
208 return __LINE__;
209
210 // UNIVERSAL_CHARSTRING operator+
211 use = use1 + uc_c;
212 us_log(use);
213 if (use != us_res_abc || use != us_res_abc_uni || use != "abc")
214 return __LINE__;
215 use = use2 + uc_c;
216 us_log(use);
217 if (use != us_res_abc || use != us_res_abc_uni || use != "abc")
218 return __LINE__;
219 use = uc_c + use1;
220 us_log(use);
221 if (use != "cab")
222 return __LINE__;
223 use = uc_c + use2;
224 us_log(use);
225 if (use != "cab")
226 return __LINE__;
227 use = use1 + uc;
228 us_log(use);
229 if (use != us_res_abX)
230 return __LINE__;
231 use = use2 + uc;
232 us_log(use);
233 if (use != us_res_abX)
234 return __LINE__;
235 use = use1 + cs_a;
236 us_log(use);
237 if (use != "aba")
238 return __LINE__;
239 use = use2 + cs_a;
240 us_log(use);
241 if (use != "aba")
242 return __LINE__;
243
244 UNIVERSAL_CHARSTRING us_from_uc(4, uc_array);
245 for (int i = 0; i < 4; i++)
246 if (us_from_uc[i] != uc_array[i] || uc_array[i] != us_from_uc[i])
247 return __LINE__;
248 CHARSTRING cs("abcd");
249 UNIVERSAL_CHARSTRING us6(cs);
250 us_log(us6);
251 if (us6 != "abcd" || "abcd" != us6)
252 return __LINE__;
253 UNIVERSAL_CHARSTRING us7(cs[0]);
254 us_log(us7);
255 if (us7 != "a" || "a" != us7)
256 return __LINE__;
257 return 0;
258 }
259
260 }
This page took 0.038486 seconds and 5 git commands to generate.