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 AnnexB2Template {
10 //import from XSD language "XML" all;
11 import from AnnexB2 all;
13 import from Flattener { function flatten };
15 modulepar boolean AnnexB2Template_verbose := false;
16 #define verbose AnnexB2Template_verbose
17 #include "../macros.ttcnin"
27 const C0container c0ct := {
31 DECLARE_EXER_ENCODERS(C0, c0);
32 DECLARE_XER_ENCODERS(C0, c0);
34 DECLARE_EXER_ENCODERS(C0container, c0c);
35 DECLARE_XER_ENCODERS(C0container, c0x);
37 DECLARE_EXER_ENCODERS(Cu, cu);
38 DECLARE_XER_ENCODERS(Cu, cu);
40 const universal charstring c0xml :=
41 "<C0 A1='1' A2='2.000000'>-1</C0>\n\n";
43 const universal charstring c0nestedstr :=
45 "\t<fld1 A1='3' A2='1.400000'>0</fld1>\n" &
49 const Cu cuval := { "What you say!" }
50 const universal charstring cuxml :=
51 "<Cu>What you say!</Cu>\n\n";
53 testcase enc_c0() runs on ic3
55 CHECK_METHOD(exer_enc_c0, valueof(t_C0), c0xml);
57 CHECK_METHOD(exer_enc_cu, cuval, cuxml);
59 CHECK_METHOD(exer_enc_c0c, c0ct, c0nestedstr);
62 testcase dec_c0() runs on ic3
64 CHECK_DECODE(exer_dec_cu, cuxml, Cu, cuval);
66 CHECK_DECODE(exer_dec_c0, c0xml, C0, valueof(t_C0));
68 CHECK_DECODE(exer_dec_c0c, c0nestedstr, C0container, c0ct);
69 CHECK_DECODE(exer_dec_c0c, flatten(c0nestedstr), C0container, c0ct);
72 DECLARE_XER_ENCODERS(strings, ss);
73 DECLARE_EXER_ENCODERS(strings, ss);
75 const universal charstring three_stooges :=
77 "\t<CHARSTRING>Larry</CHARSTRING>\n" &
78 "\t<CHARSTRING>Curly</CHARSTRING>\n" &
79 "\t<CHARSTRING>Moe</CHARSTRING>\n" &
82 const universal charstring three_stooges_b :=
85 "\t\t<CHARSTRING>Larry</CHARSTRING>\n" &
86 "\t\t<CHARSTRING>Curly</CHARSTRING>\n" &
87 "\t\t<CHARSTRING>Moe</CHARSTRING>\n" &
91 const strings stooges := {{"Larry", "Curly", "Moe"}}
93 testcase enc_strings() runs on ic3
95 CHECK_METHOD(exer_enc_ss, stooges, three_stooges);
96 CHECK_METHOD(bxer_enc_ss, stooges, three_stooges_b);
97 var universal charstring three_stooges_c := flatten(three_stooges_b);
98 CHECK_METHOD(cxer_enc_ss, stooges, three_stooges_c);
101 testcase dec_stooges() runs on ic3
103 CHECK_DECODE(exer_dec_ss, three_stooges, strings, stooges);
104 CHECK_DECODE(exer_dec_ss, flatten(three_stooges), strings, stooges);
105 CHECK_DECODE(bxer_dec_ss, three_stooges_b, strings, stooges);
112 execute(enc_strings());
113 execute(dec_stooges());
119 <?xml version="1.0" encoding="UTF-8"?>
120 <C0 A1="1" A2="2.0">-1</C0>