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 modulepar boolean Name_verbose := false;
11 #define verbose Name_verbose
12 #include "../macros.ttcnin"
14 type component alias {}
22 variant (r) "name as 'Red'";
23 variant (blue) "name as uppercased";
24 variant (black) "name as capitalized";
27 DECLARE_XER_ENCODERS(NM, nm)
28 DECLARE_EXER_ENCODERS(NM, nm)
30 const NM outfit := { r := "shirt", blue := "trousers", black := "shoes" }
32 const universal charstring str_nm_e :=
34 "\t<Red>shirt</Red>\n" &
35 "\t<BLUE>trousers</BLUE>\n" &
36 "\t<Black>shoes</Black>\n" &
39 const universal charstring str_nm_b :=
42 "\t<blue>trousers</blue>\n" &
43 "\t<black>shoes</black>\n" &
46 testcase enc_name() runs on alias
48 CHECK_METHOD(bxer_enc_nm, outfit, str_nm_b);
49 CHECK_METHOD(exer_enc_nm, outfit, str_nm_e);
52 testcase dec_name() runs on alias
54 CHECK_DECODE(bxer_dec_nm, str_nm_b, NM, outfit);
55 CHECK_DECODE(exer_dec_nm, str_nm_e, NM, outfit);
58 /* * * * * * Renaming the embedded type in a record-of * * * * * * * */
60 type record ParamType {
66 record of ParamType param_list
70 variant "name as uncapitalized";
71 variant (params.param_list[-]) "name as 'param'";
74 DECLARE_XER_ENCODERS(Call, c);
75 DECLARE_EXER_ENCODERS(Call, c);
77 const Call phone_home := {
87 const universal charstring ET := // for EXER
90 "\t\t<param_list>\n" &
92 "\t\t\t\t<caller>E.T.</caller>\n" &
94 "\t\t</param_list>\n" &
98 const universal charstring BT := // for Basic XER
101 "\t\t<param_list>\n" &
102 "\t\t\t<ParamType>\n" &
103 "\t\t\t\t<caller>E.T.</caller>\n" &
104 "\t\t\t</ParamType>\n" &
105 "\t\t</param_list>\n" &
109 testcase enc_name_recof_embed() runs on alias
111 CHECK_METHOD(bxer_enc_c, phone_home, BT);
112 CHECK_METHOD(exer_enc_c, phone_home, ET);
115 testcase dec_name_recof_embed() runs on alias
117 CHECK_DECODE(bxer_dec_c, BT, Call, phone_home);
118 CHECK_DECODE(exer_dec_c, ET, Call, phone_home);
121 /* * * * Record of a type with a "name as" (HL14920) * * * */
125 // <element name="foo" type="float"/>
128 variant "name as uncapitalized";
132 //<element name="AllData">
135 // <element ref="ns:foo" minOccurs="0" maxOccurs="unbounded"/>
139 type record AllData {
140 record of Foo foo_list
144 variant (foo_list) "untagged";
149 // For HL14920 to fire, AllData.foo_list.<oftype> needs to have
150 // a XER attribute. This variant will propagate to it.
151 variant "namespace as 'urn:trouble' prefix 'trbl'"
154 DECLARE_XER_ENCODERS(AllData, ad);
155 DECLARE_EXER_ENCODERS(AllData, ad);
157 const AllData everything := {
158 { 3.1, 4.1, 5.9, 2.6 }
161 const universal charstring bstr_all :=
164 "\t\t<Foo>3.100000</Foo>\n" &
165 "\t\t<Foo>4.100000</Foo>\n" &
166 "\t\t<Foo>5.900000</Foo>\n" &
167 "\t\t<Foo>2.600000</Foo>\n" &
171 const universal charstring estr_all :=
172 "<trbl:AllData xmlns:trbl='urn:trouble'>\n" &
173 "\t<trbl:foo>3.100000</trbl:foo>\n" &
174 "\t<trbl:foo>4.100000</trbl:foo>\n" &
175 "\t<trbl:foo>5.900000</trbl:foo>\n" &
176 "\t<trbl:foo>2.600000</trbl:foo>\n" &
177 "</trbl:AllData>\n\n";
180 testcase enc_recof_named() runs on alias
182 CHECK_METHOD(bxer_enc_ad, everything, bstr_all);
183 CHECK_METHOD(exer_enc_ad, everything, estr_all);
186 testcase dec_recof_named() runs on alias
188 CHECK_DECODE(bxer_dec_ad, bstr_all, AllData, everything);
189 CHECK_DECODE(exer_dec_ad, estr_all, AllData, everything);
196 execute(enc_name_recof_embed());
197 execute(dec_name_recof_embed());
199 execute(enc_recof_named());
200 execute(dec_recof_named());