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 AnyElementOptional2 {
10 // More complex tests for optional anyElement coding instructions
11 // Testing if omitted anyElement fields (in a record) interpret the next field or
12 // the next record as the anyElement.
14 modulepar boolean AnyElement_verbose := false;
16 #define verbose AnyElement_verbose
17 #include "../macros.ttcnin"
23 type record any_elem_outer1 {
25 any_elem_inner1 inner,
29 variant(elem_list[-]) "name as 'elem'";
32 type record any_elem_inner1 {
34 universal charstring any_elem optional,
37 variant (id) "attribute";
38 variant (any_elem) "anyElement except 'http://www.somewhere.com'";
42 type record any_elem_outer2 {
44 any_elem_inner2 inner,
48 variant(elem_list[-]) "name as 'elem'";
51 type record any_elem_inner2 {
53 universal charstring any_elem optional,
56 variant (any_elem) "anyElement except 'http://www.somewhere.com'";
60 type record any_elem_outer3 {
62 any_elem_inner3 inner,
66 variant(elem_list[-]) "name as 'elem'";
69 type record any_elem_inner3 {
71 universal charstring any_elem optional
73 variant (id) "attribute";
74 variant (any_elem) "anyElement except 'http://www.somewhere.com'";
78 type record any_elem_outer4 {
80 any_elem_inner4 inner,
84 variant(elem_list[-]) "name as 'elem'";
88 type record any_elem_inner4 {
90 universal charstring any_elem optional
92 variant (any_elem) "anyElement except 'http://www.somewhere.com'";
99 const any_elem_outer1 c_outer1 := { {
100 { inner := { 11, "<something/>", 7 } },
101 { inner := { 2, omit, 19 } },
105 const universal charstring c_outer1_enc :=
106 "<psw:any_elem_outer1 xmlns:psw='http://www.somewhere.com'>\n" &
107 "\t<psw:elem_list>\n" &
109 "\t\t\t<psw:inner id='11'>\n" &
110 "\t\t\t\t<something/>\n" &
111 "\t\t\t\t<psw:ival>7</psw:ival>\n" &
112 "\t\t\t</psw:inner>\n" &
113 "\t\t</psw:elem>\n" &
115 "\t\t\t<psw:inner id='2'>\n" &
116 "\t\t\t\t<psw:ival>19</psw:ival>\n" &
117 "\t\t\t</psw:inner>\n" &
118 "\t\t</psw:elem>\n" &
120 "\t\t\t<psw:ft>6.100000</psw:ft>\n" &
121 "\t\t</psw:elem>\n" &
122 "\t</psw:elem_list>\n" &
123 "</psw:any_elem_outer1>\n\n";
126 const any_elem_outer2 c_outer2 := { {
127 { inner := { 11, "<something/>", 7 } },
128 { inner := { 2, omit, 19 } },
132 const universal charstring c_outer2_enc :=
133 "<psw:any_elem_outer2 xmlns:psw='http://www.somewhere.com'>\n" &
134 "\t<psw:elem_list>\n" &
136 "\t\t\t<psw:inner>\n" &
137 "\t\t\t\t<psw:id>11</psw:id>\n" &
138 "\t\t\t\t<something/>\n" &
139 "\t\t\t\t<psw:ival>7</psw:ival>\n" &
140 "\t\t\t</psw:inner>\n" &
141 "\t\t</psw:elem>\n" &
143 "\t\t\t<psw:inner>\n" &
144 "\t\t\t\t<psw:id>2</psw:id>\n" &
145 "\t\t\t\t<psw:ival>19</psw:ival>\n" &
146 "\t\t\t</psw:inner>\n" &
147 "\t\t</psw:elem>\n" &
149 "\t\t\t<psw:ft>6.100000</psw:ft>\n" &
150 "\t\t</psw:elem>\n" &
151 "\t</psw:elem_list>\n" &
152 "</psw:any_elem_outer2>\n\n";
155 const any_elem_outer3 c_outer3 := { {
156 { inner := { 11, "<something/>" } },
157 { inner := { 2, omit } },
161 const universal charstring c_outer3_enc :=
162 "<psw:any_elem_outer3 xmlns:psw='http://www.somewhere.com'>\n" &
163 "\t<psw:elem_list>\n" &
165 "\t\t\t<psw:inner id='11'>\n" &
166 "\t\t\t\t<something/>\n" &
167 "\t\t\t</psw:inner>\n" &
168 "\t\t</psw:elem>\n" &
170 "\t\t\t<psw:inner id='2'/>\n" &
171 "\t\t</psw:elem>\n" &
173 "\t\t\t<psw:ft>6.100000</psw:ft>\n" &
174 "\t\t</psw:elem>\n" &
175 "\t</psw:elem_list>\n" &
176 "</psw:any_elem_outer3>\n\n";
179 const any_elem_outer4 c_outer4 := { {
180 { inner := { 11, "<something/>" } },
181 { inner := { 2, omit } },
185 const universal charstring c_outer4_enc :=
186 "<psw:any_elem_outer4 xmlns:psw='http://www.somewhere.com'>\n" &
187 "\t<psw:elem_list>\n" &
189 "\t\t\t<psw:inner>\n" &
190 "\t\t\t\t<psw:id>11</psw:id>\n" &
191 "\t\t\t\t<something/>\n" &
192 "\t\t\t</psw:inner>\n" &
193 "\t\t</psw:elem>\n" &
195 "\t\t\t<psw:inner>\n" &
196 "\t\t\t\t<psw:id>2</psw:id>\n" &
197 "\t\t\t</psw:inner>\n" &
198 "\t\t</psw:elem>\n" &
200 "\t\t\t<psw:ft>6.100000</psw:ft>\n" &
201 "\t\t</psw:elem>\n" &
202 "\t</psw:elem_list>\n" &
203 "</psw:any_elem_outer4>\n\n";
207 // Encoding & decoding functions
209 DECLARE_EXER_ENCODERS(any_elem_outer1, outer1);
210 DECLARE_EXER_ENCODERS(any_elem_outer2, outer2);
211 DECLARE_EXER_ENCODERS(any_elem_outer3, outer3);
212 DECLARE_EXER_ENCODERS(any_elem_outer4, outer4);
216 testcase encode_any_opt_complex1() runs on AE {
217 CHECK_METHOD(exer_enc_outer1, c_outer1, c_outer1_enc);
220 testcase decode_any_opt_complex1() runs on AE {
221 CHECK_DECODE(exer_dec_outer1, c_outer1_enc, any_elem_outer1, c_outer1);
224 testcase encode_any_opt_complex2() runs on AE {
225 CHECK_METHOD(exer_enc_outer2, c_outer2, c_outer2_enc);
228 testcase decode_any_opt_complex2() runs on AE {
229 CHECK_DECODE(exer_dec_outer2, c_outer2_enc, any_elem_outer2, c_outer2);
232 testcase encode_any_opt_complex3() runs on AE {
233 CHECK_METHOD(exer_enc_outer3, c_outer3, c_outer3_enc);
236 testcase decode_any_opt_complex3() runs on AE {
237 CHECK_DECODE(exer_dec_outer3, c_outer3_enc, any_elem_outer3, c_outer3);
240 testcase encode_any_opt_complex4() runs on AE {
241 CHECK_METHOD(exer_enc_outer4, c_outer4, c_outer4_enc);
244 testcase decode_any_opt_complex4() runs on AE {
245 CHECK_DECODE(exer_dec_outer4, c_outer4_enc, any_elem_outer4, c_outer4);
251 execute(encode_any_opt_complex1());
252 execute(decode_any_opt_complex1());
253 execute(encode_any_opt_complex2());
254 execute(decode_any_opt_complex2());
255 execute(encode_any_opt_complex3());
256 execute(decode_any_opt_complex3());
257 execute(encode_any_opt_complex4());
258 execute(decode_any_opt_complex4());
263 variant "namespace as 'http://www.somewhere.com' prefix 'psw'";
264 variant "elementFormQualified";