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