Titan Core Initial Contribution
[deliverable/titan.core.git] / regression_test / XML / TTCNandXML / AnyStuff.ttcnpp
CommitLineData
970ed795
EL
1/******************************************************************************
2 * Copyright (c) 2000-2014 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 ******************************************************************************/
8module AnyStuff {
9
10import from Flattener { function all }
11
12modulepar boolean AnyStuff_verbose := false;
13#define verbose AnyStuff_verbose
14#include "../macros.ttcnin"
15
16type component Anything {}
17
18type record AnyElem {
19 universal charstring Html,
20 integer num
21}
22with {
23 variant (Html) "anyElement"
24}
25
26type record UnivAnyElem {
27 universal charstring Html,
28 integer num
29}
30with {
31 variant (Html) "anyElement"
32}
33
34type record AnyElemList {
35 record of universal charstring elem_list
36 , integer f1 optional
37 , charstring f2 optional
38}
39with {
40 variant (elem_list) "anyElement" // perhaps this should now be variant (elem_list[-])
41}
42
43DECLARE_XER_ENCODERS(AnyElem, ae);
44DECLARE_EXER_ENCODERS(AnyElem, ae);
45
46DECLARE_XER_ENCODERS(UnivAnyElem, uae);
47DECLARE_EXER_ENCODERS(UnivAnyElem, uae);
48
49DECLARE_XER_ENCODERS(AnyElemList, anyt);
50DECLARE_EXER_ENCODERS(AnyElemList, anyt);
51
52const AnyElem ae1 := {
53 "<html><head><title>Hello</title></head><body>nobody</body></html>",
54 42
55}
56
57const UnivAnyElem uae1 := {
58 "<html><head><title>Hello</title></head><body>nobody</body></html>",
59 42
60}
61
62const AnyElemList aybabtu := {
63 { "<all/>", "<your/>", "<base/>", "<are/>", "<belong to='us'/>" }
64 , omit, omit
65}
66
67const AnyElemList aybabtu_expect := {
68 { "<all/>", "<your/>", "<base/>", "<are/>", "<belong to=\"us\"/>" }
69 , omit, omit
70}
71
72const universal charstring ae1str :=
73"<AnyElem>\n" &
74"\t<html><head><title>Hello</title></head><body>nobody</body></html>\n" &
75"\t<num>42</num>\n" &
76"</AnyElem>\n\n";
77
78const universal charstring ae1strb := // for Basic XER
79"<AnyElem>\n" &
80"\t<Html>&lt;html&gt;&lt;head&gt;&lt;title&gt;Hello&lt;/title&gt;&lt;/head&gt;&lt;body&gt;nobody&lt;/body&gt;&lt;/html&gt;</Html>\n" &
81"\t<num>42</num>\n" &
82"</AnyElem>\n\n";
83
84const universal charstring uae1str :=
85"<UnivAnyElem>\n" &
86"\t<html><head><title>Hello</title></head><body>nobody</body></html>\n" &
87"\t<num>42</num>\n" &
88"</UnivAnyElem>\n\n";
89
90const universal charstring uae1strb := // for Basic XER
91"<UnivAnyElem>\n" &
92"\t<Html>&lt;html&gt;&lt;head&gt;&lt;title&gt;Hello&lt;/title&gt;&lt;/head&gt;&lt;body&gt;nobody&lt;/body&gt;&lt;/html&gt;</Html>\n" &
93"\t<num>42</num>\n" &
94"</UnivAnyElem>\n\n";
95
96const universal charstring aybabtustr :=
97"<AnyElemList>\n" &
98"\t<all/>\n" &
99"\t<your/>\n" &
100"\t<base/>\n" &
101"\t<are/>\n" &
102"\t<belong to='us'/>\n" &
103"</AnyElemList>\n\n";
104
105const universal charstring aybabtustr_b :=
106"<AnyElemList>\n" &
107"\t<elem_list>\n" &
108"\t\t<UNIVERSAL_CHARSTRING>&lt;all/&gt;</UNIVERSAL_CHARSTRING>\n" &
109"\t\t<UNIVERSAL_CHARSTRING>&lt;your/&gt;</UNIVERSAL_CHARSTRING>\n" &
110"\t\t<UNIVERSAL_CHARSTRING>&lt;base/&gt;</UNIVERSAL_CHARSTRING>\n" &
111"\t\t<UNIVERSAL_CHARSTRING>&lt;are/&gt;</UNIVERSAL_CHARSTRING>\n" &
112"\t\t<UNIVERSAL_CHARSTRING>&lt;belong to=&apos;us&apos;/&gt;</UNIVERSAL_CHARSTRING>\n" &
113"\t</elem_list>\n" &
114"</AnyElemList>\n\n";
115
116
117testcase enc_anyelement() runs on Anything
118{
119 CHECK_METHOD(bxer_enc_ae, ae1, ae1strb);
120 CHECK_METHOD(exer_enc_ae, ae1, ae1str);
121
122 CHECK_METHOD(bxer_enc_uae, uae1, uae1strb);
123 CHECK_METHOD(exer_enc_uae, uae1, uae1str);
124
125 CHECK_METHOD(bxer_enc_anyt, aybabtu, aybabtustr_b);
126 CHECK_METHOD(exer_enc_anyt, aybabtu, aybabtustr);
127}
128
129testcase dec_anyelement() runs on Anything
130{
131 CHECK_DECODE(bxer_dec_ae, ae1strb, AnyElem, ae1);
132 CHECK_DECODE(exer_dec_ae, ae1str , AnyElem, ae1);
133 CHECK_DECODE(exer_dec_ae, flatten(ae1str), AnyElem, ae1);
134
135 CHECK_DECODE(bxer_dec_uae, uae1strb, UnivAnyElem, uae1);
136 CHECK_DECODE(exer_dec_uae, uae1str , UnivAnyElem, uae1);
137 CHECK_DECODE(exer_dec_uae, flatten(uae1str), UnivAnyElem, uae1);
138
139 var AnyElemList expected := aybabtu;
140 CHECK_DECODE(bxer_dec_anyt, aybabtustr_b, AnyElemList, expected);
141 //No, it should NOT do this: expected.elem_list := {}
142 //This is not an EMBED-VALUES!
143 expected := aybabtu_expect;
144 CHECK_DECODE(exer_dec_anyt, aybabtustr, AnyElemList, expected);
145 CHECK_DECODE(exer_dec_anyt, flatten(aybabtustr), AnyElemList, expected);
146}
147
148control
149{
150 execute(enc_anyelement());
151 execute(dec_anyelement());
152}
153
154}
155with { encode "XML" }
This page took 0.031221 seconds and 5 git commands to generate.