1 /******************************************************************************
2 * Copyright (c) 2000-2016 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
12 ******************************************************************************/
15 import from Flattener { function all }
17 modulepar boolean AnyStuff_verbose := false;
18 #define verbose AnyStuff_verbose
19 #include "../macros.ttcnin"
21 type component Anything {}
24 universal charstring Html,
28 variant (Html) "anyElement"
31 type record UnivAnyElem {
32 universal charstring Html,
36 variant (Html) "anyElement"
39 type record AnyElemList {
40 record of universal charstring elem_list
42 , charstring f2 optional
45 variant (elem_list) "anyElement" // perhaps this should now be variant (elem_list[-])
48 DECLARE_XER_ENCODERS(AnyElem, ae);
49 DECLARE_EXER_ENCODERS(AnyElem, ae);
51 DECLARE_XER_ENCODERS(UnivAnyElem, uae);
52 DECLARE_EXER_ENCODERS(UnivAnyElem, uae);
54 DECLARE_XER_ENCODERS(AnyElemList, anyt);
55 DECLARE_EXER_ENCODERS(AnyElemList, anyt);
57 const AnyElem ae1 := {
58 "<html><head><title>Hello</title></head><body>nobody</body></html>",
62 const UnivAnyElem uae1 := {
63 "<html><head><title>Hello</title></head><body>nobody</body></html>",
67 const AnyElemList aybabtu := {
68 { "<all/>", "<your/>", "<base/>", "<are/>", "<belong to='us'/>" }
72 const AnyElemList aybabtu_expect := {
73 { "<all/>", "<your/>", "<base/>", "<are/>", "<belong to=\"us\"/>" }
77 const universal charstring ae1str :=
79 "\t<html><head><title>Hello</title></head><body>nobody</body></html>\n" &
83 const universal charstring ae1strb := // for Basic XER
85 "\t<Html><html><head><title>Hello</title></head><body>nobody</body></html></Html>\n" &
89 const universal charstring uae1str :=
91 "\t<html><head><title>Hello</title></head><body>nobody</body></html>\n" &
95 const universal charstring uae1strb := // for Basic XER
97 "\t<Html><html><head><title>Hello</title></head><body>nobody</body></html></Html>\n" &
101 const universal charstring aybabtustr :=
107 "\t<belong to='us'/>\n" &
108 "</AnyElemList>\n\n";
110 const universal charstring aybabtustr_b :=
113 "\t\t<UNIVERSAL_CHARSTRING><all/></UNIVERSAL_CHARSTRING>\n" &
114 "\t\t<UNIVERSAL_CHARSTRING><your/></UNIVERSAL_CHARSTRING>\n" &
115 "\t\t<UNIVERSAL_CHARSTRING><base/></UNIVERSAL_CHARSTRING>\n" &
116 "\t\t<UNIVERSAL_CHARSTRING><are/></UNIVERSAL_CHARSTRING>\n" &
117 "\t\t<UNIVERSAL_CHARSTRING><belong to='us'/></UNIVERSAL_CHARSTRING>\n" &
119 "</AnyElemList>\n\n";
122 testcase enc_anyelement() runs on Anything
124 CHECK_METHOD(bxer_enc_ae, ae1, ae1strb);
125 CHECK_METHOD(exer_enc_ae, ae1, ae1str);
127 CHECK_METHOD(bxer_enc_uae, uae1, uae1strb);
128 CHECK_METHOD(exer_enc_uae, uae1, uae1str);
130 CHECK_METHOD(bxer_enc_anyt, aybabtu, aybabtustr_b);
131 CHECK_METHOD(exer_enc_anyt, aybabtu, aybabtustr);
134 testcase dec_anyelement() runs on Anything
136 CHECK_DECODE(bxer_dec_ae, ae1strb, AnyElem, ae1);
137 CHECK_DECODE(exer_dec_ae, ae1str , AnyElem, ae1);
138 CHECK_DECODE(exer_dec_ae, flatten(ae1str), AnyElem, ae1);
140 CHECK_DECODE(bxer_dec_uae, uae1strb, UnivAnyElem, uae1);
141 CHECK_DECODE(exer_dec_uae, uae1str , UnivAnyElem, uae1);
142 CHECK_DECODE(exer_dec_uae, flatten(uae1str), UnivAnyElem, uae1);
144 var AnyElemList expected := aybabtu;
145 CHECK_DECODE(bxer_dec_anyt, aybabtustr_b, AnyElemList, expected);
146 //No, it should NOT do this: expected.elem_list := {}
147 //This is not an EMBED-VALUES!
148 expected := aybabtu_expect;
149 CHECK_DECODE(exer_dec_anyt, aybabtustr, AnyElemList, expected);
150 CHECK_DECODE(exer_dec_anyt, flatten(aybabtustr), AnyElemList, expected);
155 execute(enc_anyelement());
156 execute(dec_anyelement());
160 with { encode "XML" }