Sync with 5.4.0
[deliverable/titan.core.git] / regression_test / XML / TTCNandXML / AnnexB2Template.ttcnpp
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 {
9
10 //import from XSD language "XML" all;
11 import from AnnexB2 all;
12
13 import from Flattener { function flatten };
14
15 modulepar boolean AnnexB2Template_verbose := false;
16 #define verbose AnnexB2Template_verbose
17 #include "../macros.ttcnin"
18
19 type component ic3 {}
20
21 template C0 t_C0:= {
22 a1 :=1,
23 a2 :=2.0,
24 base :=-1
25 }
26
27 const C0container c0ct := {
28 fld1 := { 3, 1.4, 0 }
29 }
30
31 DECLARE_EXER_ENCODERS(C0, c0);
32 DECLARE_XER_ENCODERS(C0, c0);
33
34 DECLARE_EXER_ENCODERS(C0container, c0c);
35 DECLARE_XER_ENCODERS(C0container, c0x);
36
37 DECLARE_EXER_ENCODERS(Cu, cu);
38 DECLARE_XER_ENCODERS(Cu, cu);
39
40 const universal charstring c0xml :=
41 "<C0 A1='1' A2='2.000000'>-1</C0>\n\n";
42
43 const universal charstring c0nestedstr :=
44 "<C0container>\n" &
45 "\t<fld1 A1='3' A2='1.400000'>0</fld1>\n" &
46 "</C0container>\n\n"
47 ;
48
49 const Cu cuval := { "What you say!" }
50 const universal charstring cuxml :=
51 "<Cu>What you say!</Cu>\n\n";
52
53 testcase enc_c0() runs on ic3
54 {
55 CHECK_METHOD(exer_enc_c0, valueof(t_C0), c0xml);
56
57 CHECK_METHOD(exer_enc_cu, cuval, cuxml);
58
59 CHECK_METHOD(exer_enc_c0c, c0ct, c0nestedstr);
60 }
61
62 testcase dec_c0() runs on ic3
63 {
64 CHECK_DECODE(exer_dec_cu, cuxml, Cu, cuval);
65
66 CHECK_DECODE(exer_dec_c0, c0xml, C0, valueof(t_C0));
67
68 CHECK_DECODE(exer_dec_c0c, c0nestedstr, C0container, c0ct);
69 CHECK_DECODE(exer_dec_c0c, flatten(c0nestedstr), C0container, c0ct);
70 }
71
72 DECLARE_XER_ENCODERS(strings, ss);
73 DECLARE_EXER_ENCODERS(strings, ss);
74
75 const universal charstring three_stooges :=
76 "<strings>\n" &
77 "\t<CHARSTRING>Larry</CHARSTRING>\n" &
78 "\t<CHARSTRING>Curly</CHARSTRING>\n" &
79 "\t<CHARSTRING>Moe</CHARSTRING>\n" &
80 "</strings>\n\n";
81
82 const universal charstring three_stooges_b :=
83 "<strings>\n" &
84 "\t<inner>\n" &
85 "\t\t<CHARSTRING>Larry</CHARSTRING>\n" &
86 "\t\t<CHARSTRING>Curly</CHARSTRING>\n" &
87 "\t\t<CHARSTRING>Moe</CHARSTRING>\n" &
88 "\t</inner>\n" &
89 "</strings>\n\n";
90
91 const strings stooges := {{"Larry", "Curly", "Moe"}}
92
93 testcase enc_strings() runs on ic3
94 {
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);
99 }
100
101 testcase dec_stooges() runs on ic3
102 {
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);
106 }
107
108 control {
109 execute(enc_c0());
110 execute(dec_c0());
111
112 execute(enc_strings());
113 execute(dec_stooges());
114 }
115
116 }
117
118 /*
119 <?xml version="1.0" encoding="UTF-8"?>
120 <C0 A1="1" A2="2.0">-1</C0>
121 */
This page took 0.108235 seconds and 5 git commands to generate.