Commit | Line | Data |
---|---|---|
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 | ******************************************************************************/ |
13 | module AttribPathTest | |
14 | { | |
15 | modulepar boolean AttribPathTest_verbose := false; | |
16 | #define verbose AttribPathTest_verbose | |
17 | ||
18 | #include "../macros.ttcnin" | |
19 | ||
20 | import from AttribPath all; | |
21 | import from Flattener { function all } | |
22 | ||
23 | type component Broadway {} | |
24 | ||
25 | DECLARE_EXER_ENCODERS(pozicio, pos); | |
26 | DECLARE_XER_ENCODERS (pozicio, pos); | |
27 | ||
28 | const 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 | |
32 | const 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 | |
41 | const 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 | ||
49 | testcase 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 | ||
55 | testcase 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 | ||
63 | DECLARE_EXER_ENCODERS(LOWpoz, lopoz); | |
64 | DECLARE_XER_ENCODERS (LOWpoz, lopoz); | |
65 | ||
66 | const LOWpoz loworugo := { 6.0, 6.6, 6.66 } | |
67 | ||
68 | // LOWpoz is in a group with "name as lowercased" | |
69 | const 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 | |
78 | const 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 | ||
86 | testcase 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 | ||
92 | testcase 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 | ||
101 | DECLARE_EXER_ENCODERS(bigpoz, bp); | |
102 | DECLARE_XER_ENCODERS (bigpoz, bp); | |
103 | ||
104 | const bigpoz bp := { 1.2, 3.4, 5.6 } | |
105 | ||
106 | // bigpoz | |
107 | const 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 | |
116 | const 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 | ||
124 | testcase 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 | ||
130 | testcase 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 | ||
139 | DECLARE_EXER_ENCODERS(SMallpoz, spoz); | |
140 | DECLARE_XER_ENCODERS (SMallpoz, spoz); | |
141 | ||
142 | const SMallpoz sp := { 1.2, 3.4, 5.6 } | |
143 | ||
144 | // smallpoz | |
145 | const 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 | |
154 | const 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 | ||
162 | testcase 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 | ||
168 | testcase 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 | |
178 | DECLARE_EXER_ENCODERS(vector, vec); | |
179 | DECLARE_XER_ENCODERS(vector, vec); | |
180 | ||
181 | const universal charstring vecstr0 := "<VECTOR>0.000000 0.000000 0.000000</VECTOR>\n\n"; | |
182 | const universal charstring vecstr1 := "<VECTOR>0.200000 0.300000 0.500000</VECTOR>\n\n"; | |
183 | const universal charstring vecstr3 := "<VECTOR>1.280000 2.560000 5.120000</VECTOR>\n\n"; | |
184 | ||
185 | const vector v0 := { 0.0, 0.0, 0.0 }; | |
186 | const vector v1 := { 0.2, 0.3, 0.5 }; | |
187 | const vector v3 := { 1.28, 2.56, 5.12 }; | |
188 | ||
189 | testcase 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 | ||
197 | testcase 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 | ||
206 | DECLARE_XER_ENCODERS(stringlist, sl); | |
207 | DECLARE_EXER_ENCODERS(stringlist, sl); | |
208 | DECLARE_XER_ENCODERS(ustringlist, usl); | |
209 | DECLARE_EXER_ENCODERS(ustringlist, usl); | |
210 | ||
211 | const stringlist three_strings := { "foo", "bar", "baz" } | |
212 | const ustringlist three_ustrings := { "foo", "bar", "baz" } | |
213 | ||
214 | const universal charstring s3_e := | |
215 | "<stringlist>foo bar baz</stringlist>\n\n"; | |
216 | ||
217 | const universal charstring us3_e := | |
218 | "<ustringlist>foo bar baz</ustringlist>\n\n"; | |
219 | ||
220 | const 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 | ||
227 | const 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 | ||
234 | testcase 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 | ||
243 | testcase 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 | ||
254 | control { | |
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 | } |