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 AnyStuff { | |
9 | ||
10 | import from Flattener { function all } | |
11 | ||
12 | modulepar boolean AnyStuff_verbose := false; | |
13 | #define verbose AnyStuff_verbose | |
14 | #include "../macros.ttcnin" | |
15 | ||
16 | type component Anything {} | |
17 | ||
18 | type record AnyElem { | |
19 | universal charstring Html, | |
20 | integer num | |
21 | } | |
22 | with { | |
23 | variant (Html) "anyElement" | |
24 | } | |
25 | ||
26 | type record UnivAnyElem { | |
27 | universal charstring Html, | |
28 | integer num | |
29 | } | |
30 | with { | |
31 | variant (Html) "anyElement" | |
32 | } | |
33 | ||
34 | type record AnyElemList { | |
35 | record of universal charstring elem_list | |
36 | , integer f1 optional | |
37 | , charstring f2 optional | |
38 | } | |
39 | with { | |
40 | variant (elem_list) "anyElement" // perhaps this should now be variant (elem_list[-]) | |
41 | } | |
42 | ||
43 | DECLARE_XER_ENCODERS(AnyElem, ae); | |
44 | DECLARE_EXER_ENCODERS(AnyElem, ae); | |
45 | ||
46 | DECLARE_XER_ENCODERS(UnivAnyElem, uae); | |
47 | DECLARE_EXER_ENCODERS(UnivAnyElem, uae); | |
48 | ||
49 | DECLARE_XER_ENCODERS(AnyElemList, anyt); | |
50 | DECLARE_EXER_ENCODERS(AnyElemList, anyt); | |
51 | ||
52 | const AnyElem ae1 := { | |
53 | "<html><head><title>Hello</title></head><body>nobody</body></html>", | |
54 | 42 | |
55 | } | |
56 | ||
57 | const UnivAnyElem uae1 := { | |
58 | "<html><head><title>Hello</title></head><body>nobody</body></html>", | |
59 | 42 | |
60 | } | |
61 | ||
62 | const AnyElemList aybabtu := { | |
63 | { "<all/>", "<your/>", "<base/>", "<are/>", "<belong to='us'/>" } | |
64 | , omit, omit | |
65 | } | |
66 | ||
67 | const AnyElemList aybabtu_expect := { | |
68 | { "<all/>", "<your/>", "<base/>", "<are/>", "<belong to=\"us\"/>" } | |
69 | , omit, omit | |
70 | } | |
71 | ||
72 | const 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 | ||
78 | const universal charstring ae1strb := // for Basic XER | |
79 | "<AnyElem>\n" & | |
80 | "\t<Html><html><head><title>Hello</title></head><body>nobody</body></html></Html>\n" & | |
81 | "\t<num>42</num>\n" & | |
82 | "</AnyElem>\n\n"; | |
83 | ||
84 | const 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 | ||
90 | const universal charstring uae1strb := // for Basic XER | |
91 | "<UnivAnyElem>\n" & | |
92 | "\t<Html><html><head><title>Hello</title></head><body>nobody</body></html></Html>\n" & | |
93 | "\t<num>42</num>\n" & | |
94 | "</UnivAnyElem>\n\n"; | |
95 | ||
96 | const 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 | ||
105 | const universal charstring aybabtustr_b := | |
106 | "<AnyElemList>\n" & | |
107 | "\t<elem_list>\n" & | |
108 | "\t\t<UNIVERSAL_CHARSTRING><all/></UNIVERSAL_CHARSTRING>\n" & | |
109 | "\t\t<UNIVERSAL_CHARSTRING><your/></UNIVERSAL_CHARSTRING>\n" & | |
110 | "\t\t<UNIVERSAL_CHARSTRING><base/></UNIVERSAL_CHARSTRING>\n" & | |
111 | "\t\t<UNIVERSAL_CHARSTRING><are/></UNIVERSAL_CHARSTRING>\n" & | |
112 | "\t\t<UNIVERSAL_CHARSTRING><belong to='us'/></UNIVERSAL_CHARSTRING>\n" & | |
113 | "\t</elem_list>\n" & | |
114 | "</AnyElemList>\n\n"; | |
115 | ||
116 | ||
117 | testcase 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 | ||
129 | testcase 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 | ||
148 | control | |
149 | { | |
150 | execute(enc_anyelement()); | |
151 | execute(dec_anyelement()); | |
152 | } | |
153 | ||
154 | } | |
155 | with { encode "XML" } |