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 namespace cstr__content
{
12 void us_log(const UNIVERSAL_CHARSTRING
& us
) {
13 TTCN_Logger::begin_event(TTCN_USER
);
15 TTCN_Logger::end_event();
18 INTEGER
tc__univ__char__cpp() {
19 const universal_char uc_array
[] = {
25 UNIVERSAL_CHARSTRING
us(1, 1, 1, 1);
26 universal_char uc
= { 1, 1, 1, 1 };
27 if (us
!= uc
|| uc
!= us
)
29 UNIVERSAL_CHARSTRING us2
;
32 if (us2
!= uc
|| uc
!= us2
)
36 if (us
!= "a" || "a" != us
)
38 UNIVERSAL_CHARSTRING
us3("abcd");
40 if (us3
!= "abcd" || "abcd" != us3
)
42 UNIVERSAL_CHARSTRING
us4(uc
);
44 if (us4
!= uc
|| uc
!= us4
)
46 UNIVERSAL_CHARSTRING
us5(4, "abcd");
48 if (us5
!= "abcd" || "abcd" != us5
)
50 const universal_char
* p_uc
= static_cast<const universal_char
*>(us5
);
51 UNIVERSAL_CHARSTRING
us_puc(4, p_uc
);
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])
58 if (us5
[0] != "b" || "b" != us5
[0] || us5
[0] != us5
[1] || us5
!= "bbcd" || "bbcd" != us5
)
62 if (us5
[0] != "a" || "a" != us5
[0] || us5
!= "abcd" || "abcd" != us5
)
67 if (us5
[0] != "x" || "x" != us5
[0] || us5
!= "xbcd" || "xbcd" != us5
)
72 if (us5
[0] != "x" || "x" != us5
[0] || us5
!= "xbcd" || "xbcd" != us5
)
84 // UNIVERSAL_CHARSTRING_ELEMENT operator+ tests
85 universal_char uc_res
[] = {
89 universal_char uc_res_abc
[] = {
94 universal_char uc_res_abX
[] = {
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
;
115 if (use
!= "ab" || "ab" != use
|| use
!= uce_res
|| uce_res
!= use
|| use
!= cse_res
|| cse_res
!= use
)
119 if (use
!= "ab" || "ab" != use
|| use
!= uce_res
|| uce_res
!= use
|| use
!= cse_res
|| cse_res
!= use
)
123 if (use
!= "ab" || "ab" != use
|| use
!= uce_res
|| uce_res
!= use
|| use
!= cse_res
|| cse_res
!= use
)
127 if (use
!= "ab" || "ab" != use
|| use
!= uce_res
|| uce_res
!= use
|| use
!= cse_res
|| cse_res
!= use
)
129 use
= use1
[0] + uc_b
;
131 if (use
!= "ab" || "ab" != use
|| use
!= uce_res
|| uce_res
!= use
|| use
!= cse_res
|| cse_res
!= use
)
133 use
= uc_a
+ use1
[1];
135 if (use
!= "ab" || "ab" != use
|| use
!= uce_res
|| uce_res
!= use
|| use
!= cse_res
|| cse_res
!= use
)
137 use
= use2
[0] + uc_b
;
139 if (use
!= "ab" || "ab" != use
|| use
!= uce_res
|| uce_res
!= use
|| use
!= cse_res
|| cse_res
!= use
)
141 use
= uc_a
+ use2
[1];
143 if (use
!= "ab" || "ab" != use
|| use
!= uce_res
|| uce_res
!= use
|| use
!= cse_res
|| cse_res
!= use
)
145 use
= use1
[0] + us_b
;
147 if (use
!= "ab" || "ab" != use
|| use
!= uce_res
|| uce_res
!= use
|| use
!= cse_res
|| cse_res
!= use
)
149 use
= us_a
+ use1
[1];
151 if (use
!= "ab" || "ab" != use
|| use
!= uce_res
|| uce_res
!= use
|| use
!= cse_res
|| cse_res
!= use
)
153 use
= use2
[0] + us_b
;
155 if (use
!= "ab" || "ab" != use
|| use
!= uce_res
|| uce_res
!= use
|| use
!= cse_res
|| cse_res
!= use
)
157 use
= us_a
+ use2
[1];
159 if (use
!= "ab" || "ab" != use
|| use
!= uce_res
|| uce_res
!= use
|| use
!= cse_res
|| cse_res
!= use
)
161 use
= use1
[0] + cs_b
;
163 if (use
!= "ab" || "ab" != use
|| use
!= uce_res
|| uce_res
!= use
|| use
!= cse_res
|| cse_res
!= use
)
165 use
= cs_a
+ use1
[1];
167 if (use
!= "ab" || "ab" != use
|| use
!= uce_res
|| uce_res
!= use
|| use
!= cse_res
|| cse_res
!= use
)
169 use
= use2
[0] + cs_b
;
171 if (use
!= "ab" || "ab" != use
|| use
!= uce_res
|| uce_res
!= use
|| use
!= cse_res
|| cse_res
!= use
)
173 use
= cs_a
+ use2
[1];
175 if (use
!= "ab" || "ab" != use
|| use
!= uce_res
|| uce_res
!= use
|| use
!= cse_res
|| cse_res
!= use
)
177 use
= use1
[0] + us_b
;
179 if (use
!= "ab" || "ab" != use
|| use
!= uce_res
|| uce_res
!= use
|| use
!= cse_res
|| cse_res
!= use
)
181 use
= us_a
+ use1
[1];
183 if (use
!= "ab" || "ab" != use
|| use
!= uce_res
|| uce_res
!= use
|| use
!= cse_res
|| cse_res
!= use
)
185 use
= use2
[0] + us_b
;
187 if (use
!= "ab" || "ab" != use
|| use
!= uce_res
|| uce_res
!= use
|| use
!= cse_res
|| cse_res
!= use
)
189 use
= us_a
+ use2
[1];
191 if (use
!= "ab" || "ab" != use
|| use
!= uce_res
|| uce_res
!= use
|| use
!= cse_res
|| cse_res
!= use
)
193 use
= use1
[0] + use1
[1];
195 if (use
!= "ab" || "ab" != use
|| use
!= uce_res
|| uce_res
!= use
|| use
!= cse_res
|| cse_res
!= use
)
197 use
= use2
[0] + use2
[1];
199 if (use
!= "ab" || "ab" != use
|| use
!= uce_res
|| uce_res
!= use
|| use
!= cse_res
|| cse_res
!= use
)
201 use
= use1
[0] + use2
[1];
203 if (use
!= "ab" || "ab" != use
|| use
!= uce_res
|| uce_res
!= use
|| use
!= cse_res
|| cse_res
!= use
)
205 use
= use2
[0] + use1
[1];
207 if (use
!= "ab" || "ab" != use
|| use
!= uce_res
|| uce_res
!= use
|| use
!= cse_res
|| cse_res
!= use
)
210 // UNIVERSAL_CHARSTRING operator+
213 if (use
!= us_res_abc
|| use
!= us_res_abc_uni
|| use
!= "abc")
217 if (use
!= us_res_abc
|| use
!= us_res_abc_uni
|| use
!= "abc")
229 if (use
!= us_res_abX
)
233 if (use
!= us_res_abX
)
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
])
248 CHARSTRING
cs("abcd");
249 UNIVERSAL_CHARSTRING
us6(cs
);
251 if (us6
!= "abcd" || "abcd" != us6
)
253 UNIVERSAL_CHARSTRING
us7(cs
[0]);
255 if (us7
!= "a" || "a" != us7
)