Sync with 5.4.0
[deliverable/titan.core.git] / regression_test / XML / TTCNandXML / AttributesTest.ttcnpp
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 AttributesTest {
9
10 modulepar boolean AttributesTest_verbose := false;
11 #define verbose AttributesTest_verbose
12 #include "../macros.ttcnin"
13
14 import from XSDAttributes all;
15 import from UTF8 all;
16
17 type component fumes {}
18
19 const Everything ev := {
20 bitstr := '00110011'B,
21 booool := true,
22 cartoon := betty,
23
24 hexen := '235'H,
25
26 wholenum := 42,
27 //emptyrec := {},
28 //objection := objid { 1 2 3 4 },
29 octets := 'DEADBEEF'O,
30 printer := "All your base are belong to us",
31 intl := "Aren_zael the master és társai",
32 upstream := 3.141592,
33 verdict := pass,
34
35 ///
36 content := omit
37 }
38
39 const universal charstring xer_everything :=
40 "<Everything>\n" &
41 "\t<bitstr>00110011</bitstr>\n" &
42 "\t<booool><true/></booool>\n" &
43
44 "\t<cartoon><betty/></cartoon>\n" &
45
46 "\t<hexen>235</hexen>\n" &
47
48 "\t<wholenum>42</wholenum>\n" &
49 "\t<octets>DEADBEEF</octets>\n" &
50 "\t<printer>All your base are belong to us</printer>\n" &
51 "\t<intl>Aren_zael the master " & eacute & "s t" & aacute & "rsai</intl>\n" &
52 "\t<upstream>3.141592</upstream>\n" &
53 "\t<verdict>pass</verdict>\n" &
54
55 "</Everything>\n\n";
56
57 const universal charstring exer_everything :=
58 "<Everything" &
59 " bitstr='00110011' booool='true' cartoon='betty' hexen='235' wholenum='42'" &
60 // " emptyrec=''" &
61 " octets='DEADBEEF' printer='All your base are belong to us'" &
62 " intl='Aren_zael the master " & eacute & "s t" & aacute & "rsai'" &
63 " upstream='3.141592' verdict='pass'/>" &
64 "\n\n";
65
66 const universal charstring xer_everything2 :=
67 "<Everything>\n" &
68 "\t<bitstr>00110011</bitstr>\n" &
69 "\t<booool><true/></booool>\n" &
70
71 "\t<cartoon><betty/></cartoon>\n" &
72
73 "\t<hexen>235</hexen>\n" &
74 "\t<wholenum>42</wholenum>\n" &
75 "\t<octets>DEADBEEF</octets>\n" &
76 "\t<printer>All your base are belong to us</printer>\n" &
77 "\t<intl>Aren_zael the master " & eacute & "s t" & aacute & "rsai</intl>\n" &
78 "\t<upstream>3.141592</upstream>\n" &
79 "\t<verdict>pass</verdict>\n" &
80
81 "\t<content>And now a word from our sponsors</content>\n" &
82
83 "</Everything>\n\n";
84
85 const universal charstring exer_everything2 :=
86 "<Everything" &
87 " bitstr='00110011' booool='true' cartoon='betty' hexen='235' wholenum='42'" &
88 // " emptyrec=''" &
89 " octets='DEADBEEF' printer='All your base are belong to us'" &
90 " intl='Aren_zael the master " & eacute & "s t" & aacute & "rsai'" &
91 " upstream='3.141592' verdict='pass'>\n" &
92 "\t<content>And now a word from our sponsors</content>\n" &
93 "</Everything>\n\n";
94
95 DECLARE_EXER_ENCODERS(Everything, ev);
96 DECLARE_XER_ENCODERS(Everything, ev);
97
98 testcase encode_everything() runs on fumes
99 {
100 var Everything input := ev;
101
102 CHECK_METHOD(exer_enc_ev, input, exer_everything);
103 CHECK_METHOD(bxer_enc_ev, input, xer_everything);
104
105 input.content := "And now a word from our sponsors";
106 CHECK_METHOD(exer_enc_ev, input, exer_everything2);
107 CHECK_METHOD(bxer_enc_ev, input, xer_everything2);
108 }
109
110 testcase decode_everything() runs on fumes
111 {
112 var Everything output := ev;
113
114 CHECK_DECODE(exer_dec_ev, exer_everything, Everything, output);
115 CHECK_DECODE(bxer_dec_ev, xer_everything, Everything, output);
116
117 output.content := "And now a word from our sponsors";
118 CHECK_DECODE(bxer_dec_ev, xer_everything2 , Everything, output);
119 CHECK_DECODE(exer_dec_ev, exer_everything2, Everything, output);
120 }
121
122 /**********************************************************************/
123
124 DECLARE_XER_ENCODERS(l_source, lsource)
125 DECLARE_EXER_ENCODERS(l_source, lsource)
126
127 // an embed of one with two attributes
128 const l_source nothing := {
129 embed := { "none" },
130 lang := omit,
131 wasei := omit
132 }
133
134 const universal charstring bxer_nothing :=
135 "<l_source>\n" &
136 "\t<embed>\n" &
137 "\t\t<UNIVERSAL_CHARSTRING>none</UNIVERSAL_CHARSTRING>\n" &
138 "\t</embed>\n" &
139 "</l_source>\n\n";
140
141 const universal charstring exer_nothing :=
142 "<l_source>" &
143 "none" &
144 "</l_source>\n";
145
146
147 const l_source lang := {
148 embed := { "lang" },
149 lang := "fra",
150 wasei := omit
151 }
152
153 const universal charstring bxer_lang :=
154 "<l_source>\n" &
155 "\t<embed>\n" &
156 "\t\t<UNIVERSAL_CHARSTRING>lang</UNIVERSAL_CHARSTRING>\n" &
157 "\t</embed>\n" &
158 "\t<lang>fra</lang>\n" &
159 "</l_source>\n\n";
160
161 const universal charstring exer_lang :=
162 "<l_source lang=\'fra\'>" &
163 "lang" &
164 "</l_source>\n";
165
166 const l_source wasei := {
167 embed := { "wasei" },
168 lang := omit,
169 wasei := "hai"
170 }
171
172 const universal charstring bxer_wasei :=
173 "<l_source>\n" &
174 "\t<embed>\n" &
175 "\t\t<UNIVERSAL_CHARSTRING>wasei</UNIVERSAL_CHARSTRING>\n" &
176 "\t</embed>\n" &
177 "\t<wasei>hai</wasei>\n" &
178 "</l_source>\n\n";
179
180 const universal charstring exer_wasei :=
181 "<l_source wasei=\'hai\'>" &
182 "wasei" &
183 "</l_source>\n";
184
185
186 const l_source both := {
187 embed := { "both" },
188 lang := "kor",
189 wasei := "blimey"
190 }
191
192 const universal charstring bxer_both :=
193 "<l_source>\n" &
194 "\t<embed>\n" &
195 "\t\t<UNIVERSAL_CHARSTRING>both</UNIVERSAL_CHARSTRING>\n" &
196 "\t</embed>\n" &
197 "\t<lang>kor</lang>\n" &
198 "\t<wasei>blimey</wasei>\n" &
199 "</l_source>\n\n";
200
201 const universal charstring exer_both :=
202 "<l_source lang=\'kor\' wasei=\'blimey\'>" &
203 "both" &
204 "</l_source>\n";
205
206
207
208 testcase encode_lsource() runs on fumes
209 {
210 CHECK_METHOD(bxer_enc_lsource, nothing, bxer_nothing);
211 CHECK_METHOD(exer_enc_lsource, nothing, exer_nothing);
212
213 CHECK_METHOD(bxer_enc_lsource, lang, bxer_lang);
214 CHECK_METHOD(exer_enc_lsource, lang, exer_lang);
215
216 CHECK_METHOD(bxer_enc_lsource, wasei, bxer_wasei);
217 CHECK_METHOD(exer_enc_lsource, wasei, exer_wasei);
218
219 CHECK_METHOD(bxer_enc_lsource, both, bxer_both);
220 CHECK_METHOD(exer_enc_lsource, both, exer_both);
221
222 }
223
224 testcase decode_lsource() runs on fumes
225 {
226 CHECK_DECODE(bxer_dec_lsource, bxer_nothing, l_source, nothing);
227 CHECK_DECODE(exer_dec_lsource, exer_nothing, l_source, nothing);
228
229 CHECK_DECODE(bxer_dec_lsource, bxer_lang, l_source, lang);
230 CHECK_DECODE(exer_dec_lsource, exer_lang, l_source, lang);
231
232 CHECK_DECODE(bxer_dec_lsource, bxer_wasei, l_source, wasei);
233 CHECK_DECODE(exer_dec_lsource, exer_wasei, l_source, wasei);
234
235 CHECK_DECODE(bxer_dec_lsource, bxer_both, l_source, both);
236 CHECK_DECODE(exer_dec_lsource, exer_both, l_source, both);
237 }
238
239 /**********************************************************************/
240
241 control {
242 execute(encode_everything());
243 execute(decode_everything());
244
245 execute(encode_lsource());
246 execute(decode_lsource());
247 }
248
249 }
This page took 0.03647 seconds and 5 git commands to generate.