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 X693amd1Test | |
9 | { | |
10 | modulepar boolean X693amd1Test_verbose := false; | |
11 | #define verbose X693amd1Test_verbose | |
12 | #include "../macros.ttcnin" | |
13 | ||
14 | import from X693amd1 all; | |
15 | import from EmbedValues { const LF }; | |
16 | import from Flattener { function flatten } | |
17 | ||
18 | type component ice {} | |
19 | ||
20 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ | |
21 | // A record with an attribute and a LIST | |
22 | ||
23 | DECLARE_XER_ENCODERS(Employee, emp); | |
24 | DECLARE_EXER_ENCODERS(Employee, emp); | |
25 | ||
26 | const universal charstring empl_b := | |
27 | "<Employee>\n" & | |
28 | "\t<id>239</id>\n" & | |
29 | "\t<recruited>27-11-2002</recruited>\n" & | |
30 | "\t<salaries>\n" & | |
31 | "\t\t<salary>29876</salary>\n" & | |
32 | "\t\t<salary>54375</salary>\n" & | |
33 | "\t\t<salary>98435</salary>\n" & | |
34 | "\t</salaries>\n" & | |
35 | "</Employee>\n" & | |
36 | "\n"; | |
37 | ||
38 | const universal charstring empl_x := | |
39 | "<employee id='239'>\n" & | |
40 | "\t<recruited>27-11-2002</recruited>\n" & | |
41 | "\t<salaries>29876 54375 98435</salaries>\n" & | |
42 | "</employee>\n" & | |
43 | "\n"; | |
44 | ||
45 | const Employee e1 := { | |
46 | id := 239, | |
47 | recruited := "27-11-2002", | |
48 | salaries := { 29876, 54375, 98435 } | |
49 | } | |
50 | ||
51 | testcase enc_employee() runs on ice | |
52 | { | |
53 | CHECK_METHOD(bxer_enc_emp, e1, empl_b); | |
54 | var universal charstring empl_c := flatten(empl_b); | |
55 | CHECK_METHOD(cxer_enc_emp, e1, empl_c); | |
56 | CHECK_METHOD(exer_enc_emp, e1, empl_x); | |
57 | } | |
58 | ||
59 | testcase dec_employee() runs on ice | |
60 | { | |
61 | CHECK_DECODE(bxer_dec_emp, empl_b, Employee, e1); | |
62 | var universal charstring empl_c := flatten(empl_b); | |
63 | CHECK_DECODE(cxer_dec_emp, empl_c, Employee, e1); | |
64 | ||
65 | CHECK_DECODE(exer_dec_emp, empl_x, Employee, e1); | |
66 | empl_c := flatten(empl_x); | |
67 | CHECK_DECODE(exer_dec_emp, empl_c, Employee, e1); | |
68 | } | |
69 | ||
70 | /* * * * * * * * * * * * * * * */ | |
71 | // CHOICE/union with USE-UNION | |
72 | ||
73 | DECLARE_XER_ENCODERS(Int_or_boolean_u, uu) | |
74 | DECLARE_EXER_ENCODERS(Int_or_boolean_u, uu) | |
75 | ||
76 | // First alternative (int) | |
77 | const Int_or_boolean_u thirty_nine := { int := 39 }; | |
78 | ||
79 | const universal charstring str_39_b := | |
80 | "<Int_or_boolean_u>\n" & | |
81 | "\t<int>39</int>\n" & | |
82 | "</Int_or_boolean_u>\n\n"; | |
83 | ||
84 | const universal charstring str_39_e := | |
85 | "<Int_or_boolean_u xmlns:p='cns' p:type='int'>39</Int_or_boolean_u>\n\n"; | |
86 | ||
87 | // Second alternative (bool) | |
88 | const Int_or_boolean_u so_true := { boolean_ := true }; | |
89 | ||
90 | const universal charstring str_true_b := | |
91 | "<Int_or_boolean_u>\n" & | |
92 | "\t<boolean_><true/></boolean_>\n" & | |
93 | "</Int_or_boolean_u>\n\n"; | |
94 | ||
95 | const universal charstring str_true_e := | |
96 | "<Int_or_boolean_u xmlns:p='cns' p:type='boolean'>true</Int_or_boolean_u>\n\n"; | |
97 | ||
98 | ||
99 | testcase enc_uu() runs on ice | |
100 | { | |
101 | CHECK_METHOD(bxer_enc_uu, thirty_nine, str_39_b); | |
102 | var universal charstring str_39_c := flatten(str_39_b); | |
103 | CHECK_METHOD(cxer_enc_uu, thirty_nine, str_39_c); | |
104 | CHECK_METHOD(exer_enc_uu, thirty_nine, str_39_e); | |
105 | ||
106 | CHECK_METHOD(bxer_enc_uu, so_true, str_true_b); | |
107 | var universal charstring str_true_c := flatten(str_true_b); | |
108 | CHECK_METHOD(cxer_enc_uu, so_true, str_true_c); | |
109 | CHECK_METHOD(exer_enc_uu, so_true, str_true_e); | |
110 | } | |
111 | ||
112 | testcase dec_uu() runs on ice | |
113 | { | |
114 | CHECK_DECODE(bxer_dec_uu, str_39_b, Int_or_boolean_u, thirty_nine); | |
115 | CHECK_DECODE(exer_dec_uu, str_39_e, Int_or_boolean_u, thirty_nine); | |
116 | ||
117 | CHECK_DECODE(bxer_dec_uu, str_true_b, Int_or_boolean_u, so_true); | |
118 | CHECK_DECODE(exer_dec_uu, str_true_e, Int_or_boolean_u, so_true); | |
119 | } | |
120 | ||
121 | /* * * * * * * * * * * * * * * */ | |
122 | // UNION/choice with USE-TYPE | |
123 | ||
124 | DECLARE_XER_ENCODERS(Int_or_boolean_t, ut) | |
125 | DECLARE_EXER_ENCODERS(Int_or_boolean_t, ut) | |
126 | ||
127 | const Int_or_boolean_t fourtytwo := { int := 42 }; | |
128 | ||
129 | const universal charstring str_42_b := | |
130 | "<Int_or_boolean_t>\n" & | |
131 | "\t<int>42</int>\n" & | |
132 | "</Int_or_boolean_t>\n\n"; | |
133 | ||
134 | const universal charstring str_42_e := | |
135 | "<Int_or_boolean_t>42</Int_or_boolean_t>\n\n"; | |
136 | // "int" is the first choice and needs no type attribute | |
137 | ||
138 | const Int_or_boolean_t so_ttrue := { boolean_ := true }; | |
139 | ||
140 | const universal charstring str_ttrue_b := | |
141 | "<Int_or_boolean_t>\n" & | |
142 | "\t<boolean_><true/></boolean_>\n" & | |
143 | "</Int_or_boolean_t>\n\n"; | |
144 | ||
145 | const universal charstring str_ttrue_e := | |
146 | "<Int_or_boolean_t xmlns:p='cns' p:type='boolean'>true</Int_or_boolean_t>\n\n"; | |
147 | ||
148 | testcase enc_ut() runs on ice | |
149 | { | |
150 | CHECK_METHOD(bxer_enc_ut, fourtytwo, str_42_b); | |
151 | var universal charstring str_42_c := flatten(str_42_b); | |
152 | CHECK_METHOD(cxer_enc_ut, fourtytwo, str_42_c); | |
153 | CHECK_METHOD(exer_enc_ut, fourtytwo, str_42_e); | |
154 | ||
155 | CHECK_METHOD(bxer_enc_ut, so_ttrue, str_ttrue_b); | |
156 | var universal charstring str_ttrue_c := flatten(str_ttrue_b); | |
157 | CHECK_METHOD(cxer_enc_ut, so_ttrue, str_ttrue_c); | |
158 | CHECK_METHOD(exer_enc_ut, so_ttrue, str_ttrue_e); | |
159 | } | |
160 | ||
161 | testcase dec_ut() runs on ice | |
162 | { | |
163 | CHECK_DECODE(bxer_dec_ut, str_ttrue_b, Int_or_boolean_t, so_ttrue); | |
164 | CHECK_DECODE(exer_dec_ut, str_ttrue_e, Int_or_boolean_t, so_ttrue); | |
165 | ||
166 | CHECK_DECODE(bxer_dec_ut, str_42_b, Int_or_boolean_t, fourtytwo); | |
167 | CHECK_DECODE(exer_dec_ut, str_42_e, Int_or_boolean_t, fourtytwo); | |
168 | } | |
169 | ||
170 | /* * * * * * * * * * * * * * * */ | |
171 | // record with record of (list) enum (useNumber) | |
172 | ||
173 | DECLARE_XER_ENCODERS(PrimeProducts, pp) | |
174 | DECLARE_EXER_ENCODERS(PrimeProducts, pp) | |
175 | ||
176 | const PrimeProducts pp := { | |
177 | { int2, int7, int17, int23, int29, int3 }, 476338.0 | |
178 | } | |
179 | ||
180 | const PrimeProducts pp0 := { | |
181 | {}, 0.0 | |
182 | } | |
183 | ||
184 | const universal charstring str_pp_b := | |
185 | "<PrimeProducts>\n" & | |
186 | "\t<input>\n" & | |
187 | "\t\t<int2/><int7/><int17/><int23/><int29/><int3/>\n" & | |
188 | "\t</input>\n" & | |
189 | "\t<output>476338.000000</output>\n" & | |
190 | "</PrimeProducts>\n\n" | |
191 | ; | |
192 | ||
193 | const universal charstring str_pp_e := | |
194 | "<PrimeProducts input=\'2 7 17 23 29 3\' output=\'476338.000000\'/>\n\n"; | |
195 | ||
196 | const universal charstring str_pp0_b := | |
197 | "<PrimeProducts>\n" & | |
198 | "\t<input/>\n" & | |
199 | "\t<output>0.000000</output>\n" & | |
200 | "</PrimeProducts>\n\n" | |
201 | ; | |
202 | ||
203 | const universal charstring str_pp0_e := | |
204 | "<PrimeProducts input=\'\' output=\'0.000000\'/>\n\n"; | |
205 | ||
206 | DECLARE_XER_ENCODERS(PrimeProductsLocalList, ppll) | |
207 | DECLARE_EXER_ENCODERS(PrimeProductsLocalList, ppll) | |
208 | ||
209 | const PrimeProductsLocalList ppll := { | |
210 | { int2, int7, int17, int23, int29, int3 }, 476338.0 | |
211 | } | |
212 | ||
213 | const PrimeProductsLocalList ppll0 := { | |
214 | {}, 0.0 | |
215 | } | |
216 | ||
217 | const universal charstring str_ppll_b := | |
218 | "<PrimeProductsLocalList>\n" & | |
219 | "\t<input>\n" & | |
220 | "\t\t<int2/><int7/><int17/><int23/><int29/><int3/>\n" & | |
221 | "\t</input>\n" & | |
222 | "\t<output>476338.000000</output>\n" & | |
223 | "</PrimeProductsLocalList>\n\n" | |
224 | ; | |
225 | ||
226 | const universal charstring str_ppll_e := | |
227 | "<PrimeProductsLocalList input=\'2 7 17 23 29 3\' output=\'476338.000000\'/>\n\n"; | |
228 | ||
229 | const universal charstring str_ppll0_b := | |
230 | "<PrimeProductsLocalList>\n" & | |
231 | "\t<input/>\n" & | |
232 | "\t<output>0.000000</output>\n" & | |
233 | "</PrimeProductsLocalList>\n\n" | |
234 | ; | |
235 | ||
236 | const universal charstring str_ppll0_e := | |
237 | "<PrimeProductsLocalList input=\'\' output=\'0.000000\'/>\n\n"; | |
238 | ||
239 | testcase enc_pp() runs on ice | |
240 | { | |
241 | CHECK_METHOD(bxer_enc_pp, pp, str_pp_b); | |
242 | var universal charstring str_pp_c := flatten(str_pp_b); | |
243 | CHECK_METHOD(cxer_enc_pp, pp, str_pp_c); | |
244 | CHECK_METHOD(exer_enc_pp, pp, str_pp_e); | |
245 | ||
246 | CHECK_METHOD(bxer_enc_pp, pp0, str_pp0_b); | |
247 | var universal charstring str_pp0_c := flatten(str_pp0_b); | |
248 | CHECK_METHOD(cxer_enc_pp, pp0, str_pp0_c); | |
249 | CHECK_METHOD(exer_enc_pp, pp0, str_pp0_e); | |
250 | ||
251 | CHECK_METHOD(bxer_enc_ppll, ppll, str_ppll_b); | |
252 | var universal charstring str_ppll_c := flatten(str_ppll_b); | |
253 | CHECK_METHOD(cxer_enc_ppll, ppll, str_ppll_c); | |
254 | CHECK_METHOD(exer_enc_ppll, ppll, str_ppll_e); | |
255 | ||
256 | CHECK_METHOD(bxer_enc_ppll, ppll0, str_ppll0_b); | |
257 | var universal charstring str_ppll0_c := flatten(str_ppll0_b); | |
258 | CHECK_METHOD(cxer_enc_ppll, ppll0, str_ppll0_c); | |
259 | CHECK_METHOD(exer_enc_ppll, ppll0, str_ppll0_e); | |
260 | } | |
261 | ||
262 | testcase dec_pp() runs on ice | |
263 | { | |
264 | CHECK_DECODE(bxer_dec_pp, str_pp_b, PrimeProducts, pp); | |
265 | CHECK_DECODE(exer_dec_pp, str_pp_e, PrimeProducts, pp); | |
266 | ||
267 | CHECK_DECODE(bxer_dec_pp, str_pp0_b, PrimeProducts, pp0); | |
268 | CHECK_DECODE(exer_dec_pp, str_pp0_e, PrimeProducts, pp0); | |
269 | } | |
270 | ||
271 | /* * * * * * * * * * * * * * * */ | |
272 | // USE-NIL | |
273 | ||
274 | DECLARE_XER_ENCODERS(nilluser, nil) | |
275 | DECLARE_EXER_ENCODERS(nilluser, nil) | |
276 | ||
277 | const nilluser here := { "here", 42 } | |
278 | const universal charstring str_here_b := | |
279 | "<nilluser>\n" & | |
280 | "\t<title>here</title>\n" & | |
281 | "\t<maybe>42</maybe>\n" & | |
282 | "</nilluser>\n\n" ; | |
283 | ||
284 | const universal charstring str_here_e := | |
285 | "<nilluser title=\'here\'>42</nilluser>\n\n"; | |
286 | ||
287 | const nilluser nope := { "nope", omit } | |
288 | ||
289 | const universal charstring str_nope_b := | |
290 | "<nilluser>\n" & | |
291 | "\t<title>nope</title>\n" & | |
292 | "</nilluser>\n\n" ; | |
293 | ||
294 | const universal charstring str_nope_e := | |
295 | "<nilluser xmlns:p='cns' title=\'nope\' p:nil=\'true\'/>\n\n"; | |
296 | ||
297 | testcase enc_nil() runs on ice | |
298 | { | |
299 | CHECK_METHOD(bxer_enc_nil, here, str_here_b); | |
300 | var universal charstring str_here_c := flatten(str_here_b); | |
301 | CHECK_METHOD(cxer_enc_nil, here, str_here_c); | |
302 | CHECK_METHOD(exer_enc_nil, here, str_here_e); | |
303 | ||
304 | CHECK_METHOD(bxer_enc_nil, nope, str_nope_b); | |
305 | var universal charstring str_nope_c := flatten(str_nope_b); | |
306 | CHECK_METHOD(cxer_enc_nil, nope, str_nope_c); | |
307 | CHECK_METHOD(exer_enc_nil, nope, str_nope_e); | |
308 | } | |
309 | ||
310 | testcase dec_nil() runs on ice | |
311 | { | |
312 | CHECK_DECODE(bxer_dec_nil, str_here_b, nilluser, here); | |
313 | var universal charstring str_here_c := flatten(str_here_b); | |
314 | CHECK_DECODE(cxer_dec_nil, str_here_c, nilluser, here); | |
315 | CHECK_DECODE(exer_dec_nil, str_here_e, nilluser, here); | |
316 | ||
317 | CHECK_DECODE(bxer_dec_nil, str_nope_b, nilluser, nope); | |
318 | var universal charstring str_nope_c := flatten(str_nope_b); | |
319 | CHECK_DECODE(cxer_dec_nil, str_nope_c, nilluser, nope); | |
320 | ||
321 | CHECK_DECODE(exer_dec_nil, str_nope_e, nilluser, nope); | |
322 | } | |
323 | ||
324 | /* * * * * * * * * * * * * * * */ | |
325 | // DEFAULT-FOR-EMPTY | |
326 | ||
327 | DECLARE_XER_ENCODERS(CallDetails, cd) | |
328 | DECLARE_EXER_ENCODERS(CallDetails, cd) | |
329 | ||
330 | DECLARE_XER_ENCODERS(CallDetails0, cd0) | |
331 | DECLARE_EXER_ENCODERS(CallDetails0, cd0) | |
332 | ||
333 | DECLARE_XER_ENCODERS(CallDetails_indirect, cdi) | |
334 | DECLARE_EXER_ENCODERS(CallDetails_indirect, cdi) | |
335 | ||
336 | /***************** The default value *****************/ | |
337 | // CallDetails default for empty is number_not_known | |
338 | const CallDetails unk := { | |
339 | number := "0164593746", // attribute | |
340 | response := number_not_known // d-f-e value | |
341 | } | |
342 | ||
343 | const universal charstring str_unk_b := | |
344 | "<CallDetails>\n" & | |
345 | "\t<number>0164593746</number>\n" & | |
346 | "\t<response><number_not_known/></response>\n" & // Basic XER, never omitted | |
347 | "</CallDetails>\n\n"; | |
348 | ||
349 | const universal charstring str_unk_e_enc := // EXER, "number-not-known" not omitted when encoding | |
350 | "<CallDetails number=\'0164593746\'>number-not-known</CallDetails>\n\n"; | |
351 | ||
352 | const universal charstring str_unk_e_dec := // EXER, "number-not-known" omitted can be decoded | |
353 | "<CallDetails number=\'0164593746\'/>\n\n"; | |
354 | ||
355 | testcase enc_dfe_unk() runs on ice | |
356 | { | |
357 | CHECK_METHOD(bxer_enc_cd, unk, str_unk_b); | |
358 | var universal charstring str_unk_c := flatten(str_unk_b); | |
359 | CHECK_METHOD(cxer_enc_cd, unk, str_unk_c); | |
360 | CHECK_METHOD(exer_enc_cd, unk, str_unk_e_enc); | |
361 | } | |
362 | ||
363 | testcase dec_dfe_unk() runs on ice | |
364 | { | |
365 | CHECK_DECODE(bxer_dec_cd, str_unk_b, CallDetails, unk); | |
366 | var universal charstring str_unk_c := flatten(str_unk_b); | |
367 | CHECK_DECODE(cxer_dec_cd, str_unk_c, CallDetails, unk); | |
368 | ||
369 | // EXER must decode both omitted and not-omitted | |
370 | CHECK_DECODE(exer_dec_cd, str_unk_e_enc , CallDetails, unk); | |
371 | CHECK_DECODE(exer_dec_cd, str_unk_e_dec , CallDetails, unk); | |
372 | } | |
373 | ||
374 | /***************** A non-default value *****************/ | |
375 | ||
376 | const CallDetails ring :={ | |
377 | number := "555-555-555", // attribute | |
378 | response := ringing // not d-f-e value | |
379 | } | |
380 | ||
381 | const universal charstring str_ring_b := | |
382 | "<CallDetails>\n" & | |
383 | "\t<number>555-555-555</number>\n" & | |
384 | "\t<response><ringing/></response>\n" & // Basic XER, never omitted | |
385 | "</CallDetails>\n\n"; | |
386 | ||
387 | const universal charstring str_ring_e := | |
388 | "<CallDetails number=\'555-555-555\'>" & | |
389 | "ringing" & // EXER, untagged, not the default value | |
390 | "</CallDetails>\n\n"; | |
391 | ||
392 | testcase enc_dfe_ring() runs on ice | |
393 | { | |
394 | CHECK_METHOD(bxer_enc_cd, ring, str_ring_b); | |
395 | var universal charstring str_ring_c := flatten(str_ring_b); | |
396 | CHECK_METHOD(cxer_enc_cd, ring, str_ring_c); | |
397 | CHECK_METHOD(exer_enc_cd, ring, str_ring_e); | |
398 | } | |
399 | ||
400 | testcase dec_dfe_ring() runs on ice | |
401 | { | |
402 | CHECK_DECODE(bxer_dec_cd, str_ring_b, CallDetails, ring); | |
403 | var universal charstring str_ring_c := flatten(str_ring_b); | |
404 | CHECK_DECODE(cxer_dec_cd, str_ring_c, CallDetails, ring); | |
405 | CHECK_DECODE(exer_dec_cd, str_ring_e, CallDetails, ring); | |
406 | } | |
407 | ||
408 | ||
409 | /***************** value doesn't matter if no DFE *****************/ | |
410 | ||
411 | // CallDetails0 has no default for empty | |
412 | const CallDetails0 unk_0 := { | |
413 | number := "0164593746", | |
414 | response := number_not_known | |
415 | } | |
416 | ||
417 | const universal charstring str_unk_0e := str_unk_e_enc | |
418 | ||
419 | const universal charstring str_unk_0b := | |
420 | "<CallDetails0>\n" & | |
421 | "\t<number>0164593746</number>\n" & | |
422 | "\t<response><number_not_known/></response>\n" & // Basic XER, never omitted | |
423 | "</CallDetails0>\n\n"; | |
424 | ||
425 | ||
426 | testcase enc_dfe_unk0() runs on ice | |
427 | { | |
428 | CHECK_METHOD(bxer_enc_cd0, unk_0, str_unk_0b); | |
429 | CHECK_METHOD(exer_enc_cd0, unk_0, str_unk_0e); | |
430 | } | |
431 | ||
432 | testcase dec_dfe_unk0() runs on ice | |
433 | { | |
434 | // Basic and Canonical XER is the same for CallDetails0 and | |
435 | // CallDetails_indirect, except for the tag name | |
436 | CHECK_DECODE(bxer_dec_cd0, str_unk_0b, CallDetails0, unk_0); | |
437 | CHECK_DECODE(exer_dec_cd0, str_unk_0e, CallDetails0, unk_0); | |
438 | // no test for omitted, no DFE for CallDetails0 | |
439 | } | |
440 | ||
441 | ||
442 | const CallDetails0 ring_0 :={ | |
443 | number := "555-555-555", | |
444 | response := ringing | |
445 | } | |
446 | ||
447 | const universal charstring str_ring_0b := | |
448 | "<CallDetails0>\n" & | |
449 | "\t<number>555-555-555</number>\n" & | |
450 | "\t<response><ringing/></response>\n" & // Basic XER, never omitted | |
451 | "</CallDetails0>\n\n"; | |
452 | ||
453 | // CallDetails0 has a "name as CallDetails" (does not apply to BXER, above) | |
454 | const universal charstring str_ring_0e := str_ring_e | |
455 | ||
456 | testcase enc_dfe_ring0() runs on ice | |
457 | { | |
458 | CHECK_METHOD(bxer_enc_cd0, ring_0, str_ring_0b); | |
459 | CHECK_METHOD(exer_enc_cd0, ring_0, str_ring_0e); | |
460 | } | |
461 | ||
462 | testcase dec_dfe_ring0() runs on ice | |
463 | { | |
464 | // Basic and Canonical XER is the same for CallDetails0 and | |
465 | // CallDetails_indirect, except for the tag name | |
466 | CHECK_DECODE(bxer_dec_cd0, str_ring_0b, CallDetails0, ring_0); | |
467 | CHECK_DECODE(exer_dec_cd0, str_ring_0e, CallDetails0, ring_0); | |
468 | } | |
469 | ||
470 | /***************** Now the late-apply DFE *****************/ | |
471 | ||
472 | // CallDetails_indirect default for empty is ringing | |
473 | const CallDetails_indirect unk_i := { | |
474 | number := "0164593746", | |
475 | response := number_not_known // not the default value | |
476 | } | |
477 | ||
478 | const universal charstring str_unki_b := | |
479 | "<CallDetails_indirect>\n" & | |
480 | "\t<number>0164593746</number>\n" & | |
481 | "\t<response><number_not_known/></response>\n" & // Basic XER, never omitted | |
482 | "</CallDetails_indirect>\n\n"; | |
483 | ||
484 | const universal charstring str_unki_e := | |
485 | "<CallDetails number=\'0164593746\'>" & | |
486 | "number-not-known" & // EXER, untagged, not the default value | |
487 | "</CallDetails>\n\n"; | |
488 | ||
489 | testcase enc_dfe_unki() runs on ice | |
490 | { | |
491 | CHECK_METHOD(bxer_enc_cdi, unk_i, str_unki_b); | |
492 | var universal charstring str_unki_c := flatten(str_unki_b); | |
493 | CHECK_METHOD(cxer_enc_cdi, unk_i, str_unki_c); | |
494 | CHECK_METHOD(exer_enc_cdi, unk_i, str_unki_e); | |
495 | } | |
496 | ||
497 | testcase dec_dfe_unki() runs on ice | |
498 | { | |
499 | CHECK_DECODE(bxer_dec_cdi, str_unki_b, CallDetails_indirect, unk_i); | |
500 | var universal charstring str_unki_c := flatten(str_unki_b); | |
501 | CHECK_DECODE(cxer_dec_cdi, str_unki_c, CallDetails_indirect, unk_i); | |
502 | CHECK_DECODE(exer_dec_cdi, str_unki_e, CallDetails_indirect, unk_i); | |
503 | } | |
504 | ||
505 | /***************** Now the default value *****************/ | |
506 | const CallDetails_indirect ring_i :={ | |
507 | number := "555-555-555", | |
508 | response := ringing // default value | |
509 | } | |
510 | ||
511 | const universal charstring str_ringi_b := | |
512 | "<CallDetails_indirect>\n" & | |
513 | "\t<number>555-555-555</number>\n" & | |
514 | "\t<response><ringing/></response>\n" & // Basic XER, never omitted | |
515 | "</CallDetails_indirect>\n\n"; | |
516 | ||
517 | const universal charstring str_ringi_e_enc := | |
518 | "<CallDetails number=\'555-555-555\'>ringing</CallDetails>\n\n"; // EXER, not omitted when encoding | |
519 | ||
520 | const universal charstring str_ringi_e_dec := | |
521 | "<CallDetails number=\'555-555-555\'/>\n\n"; // EXER, "ringing" omitted | |
522 | ||
523 | ||
524 | testcase enc_dfe_ringi() runs on ice | |
525 | { | |
526 | CHECK_METHOD(bxer_enc_cdi, ring_i, str_ringi_b); | |
527 | var universal charstring str_ringi_c := flatten(str_ringi_b); | |
528 | CHECK_METHOD(cxer_enc_cdi, ring_i, str_ringi_c); | |
529 | CHECK_METHOD(exer_enc_cdi, ring_i, str_ringi_e_enc); | |
530 | } | |
531 | ||
532 | testcase dec_dfe_ringi() runs on ice | |
533 | { | |
534 | CHECK_DECODE(bxer_dec_cdi, str_ringi_b, CallDetails_indirect, ring_i); | |
535 | var universal charstring str_ringi_c := flatten(str_ringi_b); | |
536 | CHECK_DECODE(cxer_dec_cdi, str_ringi_c, CallDetails_indirect, ring_i); | |
537 | // Must decode both forms | |
538 | CHECK_DECODE(exer_dec_cdi, str_ringi_e_enc, CallDetails_indirect, ring_i); | |
539 | CHECK_DECODE(exer_dec_cdi, str_ringi_e_dec, CallDetails_indirect, ring_i); | |
540 | } | |
541 | ||
542 | /* * * * * * * * * * * * * * * */ | |
543 | // Test for TEXT | |
544 | DECLARE_XER_ENCODERS (State, st) | |
545 | DECLARE_EXER_ENCODERS(State, st) | |
546 | ||
547 | const State magic := magic; | |
548 | const State more_magic := more_magic; | |
549 | ||
550 | const universal charstring str_magic_b := | |
551 | "<State><magic/></State>\n" & LF; | |
552 | const universal charstring str_magic_e := | |
553 | "<state>Magic</state>\n" & LF; | |
554 | ||
555 | const universal charstring str_more_magic_b := | |
556 | "<State><more_magic/></State>\n" & LF; | |
557 | const universal charstring str_more_magic_e := | |
558 | "<state>off</state>\n" & LF; | |
559 | ||
560 | ||
561 | testcase enc_txt() runs on ice | |
562 | { | |
563 | CHECK_METHOD(bxer_enc_st, magic, str_magic_b); | |
564 | var universal charstring str_magic_c := flatten(str_magic_b); | |
565 | CHECK_METHOD(cxer_enc_st, magic, str_magic_c); | |
566 | CHECK_METHOD(exer_enc_st, magic, str_magic_e); | |
567 | ||
568 | CHECK_METHOD(bxer_enc_st, more_magic, str_more_magic_b); | |
569 | var universal charstring str_more_magic_c := flatten(str_more_magic_b); | |
570 | CHECK_METHOD(cxer_enc_st, more_magic, str_more_magic_c); | |
571 | CHECK_METHOD(exer_enc_st, more_magic, str_more_magic_e); | |
572 | } | |
573 | ||
574 | /* * * * * * * * * * * * * * * */ | |
575 | ||
576 | DECLARE_XER_ENCODERS (Nillable, nl) | |
577 | DECLARE_EXER_ENCODERS(Nillable, nl) | |
578 | ||
579 | const Nillable omitted := { content := omit }; | |
580 | const universal charstring nilstr := | |
581 | "<Nillable/>\n\n"; | |
582 | ||
583 | const universal charstring nilstr_e := | |
584 | "<Nillable xmlns:p='cns' p:nil='true'/>\n\n"; | |
585 | ||
586 | testcase enc_nillable() runs on ice | |
587 | { | |
588 | CHECK_METHOD(bxer_enc_nl, omitted, nilstr); | |
589 | var universal charstring nilstr_c := flatten(nilstr); | |
590 | CHECK_METHOD(cxer_enc_nl, omitted, nilstr_c); | |
591 | CHECK_METHOD(exer_enc_nl, omitted, nilstr_e); | |
592 | } | |
593 | ||
594 | control { | |
595 | execute(enc_employee()) | |
596 | execute(dec_employee()) | |
597 | ||
598 | execute(enc_uu()) | |
599 | execute(dec_uu()) | |
600 | ||
601 | execute(enc_ut()) | |
602 | execute(dec_ut()) | |
603 | ||
604 | execute(enc_pp()) | |
605 | execute(dec_pp()) | |
606 | ||
607 | execute(enc_nil()) | |
608 | execute(dec_nil()) | |
609 | ||
610 | execute(enc_dfe_unk()) | |
611 | execute(dec_dfe_unk()) | |
612 | execute(enc_dfe_ring()) | |
613 | execute(dec_dfe_ring()) | |
614 | execute(enc_dfe_unk0()) | |
615 | execute(dec_dfe_unk0()) | |
616 | execute(enc_dfe_ring0()) | |
617 | execute(dec_dfe_ring0()) | |
618 | execute(enc_dfe_unki()) | |
619 | execute(dec_dfe_unki()) | |
620 | execute(enc_dfe_ringi()) | |
621 | execute(dec_dfe_ringi()) | |
622 | ||
623 | execute(enc_txt()) | |
624 | ||
625 | execute(enc_nillable()) | |
626 | } | |
627 | ||
628 | } |