Last sync 2016.04.01
[deliverable/titan.core.git] / regression_test / XML / TTCNandXML / AttribPathTest.ttcnpp
CommitLineData
970ed795 1/******************************************************************************
d44e3c4f 2 * Copyright (c) 2000-2016 Ericsson Telecom AB
970ed795
EL
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
d44e3c4f 7 *
8 * Contributors:
9 * Balasko, Jeno
10 * Raduly, Csaba
11 *
970ed795
EL
12 ******************************************************************************/
13module AttribPathTest
14{
15modulepar boolean AttribPathTest_verbose := false;
16#define verbose AttribPathTest_verbose
17
18#include "../macros.ttcnin"
19
20import from AttribPath all;
21import from Flattener { function all }
22
23type component Broadway {}
24
25DECLARE_EXER_ENCODERS(pozicio, pos);
26DECLARE_XER_ENCODERS (pozicio, pos);
27
28const pozicio prima := { 2.0, 3.0, 5.0 }
29
30// pozicio is inside a group with "name as uppercased"
31// and x,y,z all have "name as" attributes
32const universal charstring etalon_ext :=
33"<POZICIO>\n" &
34"\t<width>2.000000</width>\n" &
35"\t<depth>3.000000</depth>\n" &
36"\t<height>5.000000</height>\n" &
37"</POZICIO>\n\n"
38;
39
40// Basic XER ignores encoding instructions
41const universal charstring etalon_basic :=
42"<pozicio>\n" &
43"\t<x>2.000000</x>\n" &
44"\t<y>3.000000</y>\n" &
45"\t<z>5.000000</z>\n" &
46"</pozicio>\n\n"
47;
48
49testcase enc_upcase() runs on Broadway
50{
51 CHECK_METHOD(exer_enc_pos, prima, etalon_ext)
52 CHECK_METHOD(bxer_enc_pos, prima, etalon_basic);
53}
54
55testcase dec_upcase() runs on Broadway
56{
57 CHECK_DECODE(exer_dec_pos, etalon_ext , pozicio, prima);
58 CHECK_DECODE(exer_dec_pos, flatten(etalon_ext) , pozicio, prima);
59 CHECK_DECODE(bxer_dec_pos, etalon_basic , pozicio, prima);
60}
61/************************************************************************/
62
63DECLARE_EXER_ENCODERS(LOWpoz, lopoz);
64DECLARE_XER_ENCODERS (LOWpoz, lopoz);
65
66const LOWpoz loworugo := { 6.0, 6.6, 6.66 }
67
68// LOWpoz is in a group with "name as lowercased"
69const universal charstring etalon_low :=
70"<lowpoz>\n" &
71"\t<width>6.000000</width>\n" &
72"\t<depth>6.600000</depth>\n" &
73"\t<height>6.660000</height>\n" &
74"</lowpoz>\n\n"
75;
76
77// Basic XER for lowpoz
78const universal charstring etalon_low_basic :=
79"<LOWpoz>\n" &
80"\t<x>6.000000</x>\n" &
81"\t<y>6.600000</y>\n" &
82"\t<z>6.660000</z>\n" &
83"</LOWpoz>\n\n"
84;
85
86testcase enc_locase() runs on Broadway
87{
88 CHECK_METHOD(exer_enc_lopoz, loworugo, etalon_low);
89 CHECK_METHOD(bxer_enc_lopoz, loworugo, etalon_low_basic);
90}
91
92testcase dec_locase() runs on Broadway
93{
94 CHECK_DECODE(exer_dec_lopoz, etalon_low , LOWpoz, loworugo);
95 CHECK_DECODE(exer_dec_lopoz, flatten(etalon_low), LOWpoz, loworugo);
96 CHECK_DECODE(bxer_dec_lopoz, etalon_low_basic , LOWpoz, loworugo);
97}
98
99/************************************************************************/
100
101DECLARE_EXER_ENCODERS(bigpoz, bp);
102DECLARE_XER_ENCODERS (bigpoz, bp);
103
104const bigpoz bp := { 1.2, 3.4, 5.6 }
105
106// bigpoz
107const universal charstring etalon_big :=
108"<Bigpoz>\n" &
109"\t<width>1.200000</width>\n" &
110"\t<depth>3.400000</depth>\n" &
111"\t<height>5.600000</height>\n" &
112"</Bigpoz>\n\n"
113;
114
115// Basic XER for bigpoz
116const universal charstring etalon_big_basic :=
117"<bigpoz>\n" &
118"\t<x>1.200000</x>\n" &
119"\t<y>3.400000</y>\n" &
120"\t<z>5.600000</z>\n" &
121"</bigpoz>\n\n"
122;
123
124testcase enc_capital() runs on Broadway
125{
126 CHECK_METHOD(exer_enc_bp, bp, etalon_big);
127 CHECK_METHOD(bxer_enc_bp, bp, etalon_big_basic);
128}
129
130testcase dec_capital() runs on Broadway
131{
132 CHECK_DECODE(exer_dec_bp, etalon_big , bigpoz, bp);
133 CHECK_DECODE(exer_dec_bp, flatten(etalon_big), bigpoz, bp);
134 CHECK_DECODE(bxer_dec_bp, etalon_big_basic , bigpoz, bp);
135}
136
137/************************************************************************/
138
139DECLARE_EXER_ENCODERS(SMallpoz, spoz);
140DECLARE_XER_ENCODERS (SMallpoz, spoz);
141
142const SMallpoz sp := { 1.2, 3.4, 5.6 }
143
144// smallpoz
145const universal charstring etalon_small :=
146"<sMallpoz>\n" &
147"\t<width>1.200000</width>\n" &
148"\t<depth>3.400000</depth>\n" &
149"\t<height>5.600000</height>\n" &
150"</sMallpoz>\n\n"
151;
152
153// Basic XER for smallpoz
154const universal charstring etalon_small_basic :=
155"<SMallpoz>\n" &
156"\t<x>1.200000</x>\n" &
157"\t<y>3.400000</y>\n" &
158"\t<z>5.600000</z>\n" &
159"</SMallpoz>\n\n"
160;
161
162testcase enc_uncapital() runs on Broadway
163{
164 CHECK_METHOD(exer_enc_spoz, sp, etalon_small);
165 CHECK_METHOD(bxer_enc_spoz, sp, etalon_small_basic);
166}
167
168testcase dec_uncapital() runs on Broadway
169{
170 CHECK_DECODE(exer_dec_spoz, etalon_small , SMallpoz, sp);
171 CHECK_DECODE(exer_dec_spoz, flatten(etalon_small), SMallpoz, sp);
172 CHECK_DECODE(bxer_dec_spoz, etalon_small_basic , SMallpoz, sp);
173}
174
175/************************************************************************/
176
177// vector is a record-of float with LIST
178DECLARE_EXER_ENCODERS(vector, vec);
179DECLARE_XER_ENCODERS(vector, vec);
180
181const universal charstring vecstr0 := "<VECTOR>0.000000 0.000000 0.000000</VECTOR>\n\n";
182const universal charstring vecstr1 := "<VECTOR>0.200000 0.300000 0.500000</VECTOR>\n\n";
183const universal charstring vecstr3 := "<VECTOR>1.280000 2.560000 5.120000</VECTOR>\n\n";
184
185const vector v0 := { 0.0, 0.0, 0.0 };
186const vector v1 := { 0.2, 0.3, 0.5 };
187const vector v3 := { 1.28, 2.56, 5.12 };
188
189testcase enc_vector() runs on Broadway
190{
191
192 CHECK_METHOD(exer_enc_vec, v0, vecstr0);
193 CHECK_METHOD(exer_enc_vec, v1, vecstr1);
194 CHECK_METHOD(exer_enc_vec, v3, vecstr3);
195}
196
197testcase dec_vector() runs on Broadway
198{
199 CHECK_DECODE(exer_dec_vec, vecstr0, vector, v0);
200 CHECK_DECODE(exer_dec_vec, vecstr1, vector, v1);
201 CHECK_DECODE(exer_dec_vec, vecstr3, vector, v3);
202}
203
204/************************************************************************/
205
206DECLARE_XER_ENCODERS(stringlist, sl);
207DECLARE_EXER_ENCODERS(stringlist, sl);
208DECLARE_XER_ENCODERS(ustringlist, usl);
209DECLARE_EXER_ENCODERS(ustringlist, usl);
210
211const stringlist three_strings := { "foo", "bar", "baz" }
212const ustringlist three_ustrings := { "foo", "bar", "baz" }
213
214const universal charstring s3_e :=
215"<stringlist>foo bar baz</stringlist>\n\n";
216
217const universal charstring us3_e :=
218"<ustringlist>foo bar baz</ustringlist>\n\n";
219
220const universal charstring s3_b :=
221"<stringlist>\n" &
222"\t<CHARSTRING>foo</CHARSTRING>\n" &
223"\t<CHARSTRING>bar</CHARSTRING>\n" &
224"\t<CHARSTRING>baz</CHARSTRING>\n" &
225"</stringlist>\n\n";
226
227const universal charstring us3_b :=
228"<ustringlist>\n" &
229"\t<UNIVERSAL_CHARSTRING>foo</UNIVERSAL_CHARSTRING>\n" &
230"\t<UNIVERSAL_CHARSTRING>bar</UNIVERSAL_CHARSTRING>\n" &
231"\t<UNIVERSAL_CHARSTRING>baz</UNIVERSAL_CHARSTRING>\n" &
232"</ustringlist>\n\n";
233
234testcase enc_stringlist() runs on Broadway
235{
236 CHECK_METHOD(exer_enc_sl, three_strings, s3_e);
237 CHECK_METHOD(bxer_enc_sl, three_strings, s3_b);
238
239 CHECK_METHOD(exer_enc_usl, three_ustrings, us3_e);
240 CHECK_METHOD(bxer_enc_usl, three_ustrings, us3_b);
241}
242
243testcase dec_stringlist() runs on Broadway
244{
245 CHECK_DECODE(bxer_dec_usl, us3_b, ustringlist, three_ustrings);
246 CHECK_DECODE(exer_dec_usl, us3_e, ustringlist, three_ustrings);
247
248 CHECK_DECODE(bxer_dec_sl, s3_b, stringlist, three_strings);
249 CHECK_DECODE(exer_dec_sl, s3_e, stringlist, three_strings);
250}
251
252/************************************************************************/
253
254control {
255 execute( enc_upcase() );
256 execute( enc_locase() );
257 execute( enc_capital() );
258 execute( enc_uncapital() );
259
260 execute( dec_upcase() );
261 execute( dec_locase() );
262 execute( dec_capital() );
263 execute( dec_uncapital() );
264
265 execute( enc_vector() );
266 execute( dec_vector() );
267
268 execute( enc_stringlist() );
269 execute( dec_stringlist() );
270}
271
272}
This page took 0.038262 seconds and 5 git commands to generate.