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 AttributesTest {
10 modulepar boolean AttributesTest_verbose := false;
11 #define verbose AttributesTest_verbose
12 #include "../macros.ttcnin"
14 import from XSDAttributes all;
17 type component fumes {}
19 const Everything ev := {
20 bitstr := '00110011'B,
28 //objection := objid { 1 2 3 4 },
29 octets := 'DEADBEEF'O,
30 printer := "All your base are belong to us",
31 intl := "Aren_zael the master és társai",
39 const universal charstring xer_everything :=
41 "\t<bitstr>00110011</bitstr>\n" &
42 "\t<booool><true/></booool>\n" &
44 "\t<cartoon><betty/></cartoon>\n" &
46 "\t<hexen>235</hexen>\n" &
48 "\t<wholenum>42</wholenum>\n" &
49 "\t<octets>DEADBEEF</octets>\n" &
50 "\t<printer>All your base are belong to us</printer>\n" &
51 "\t<intl>Aren_zael the master " & eacute & "s t" & aacute & "rsai</intl>\n" &
52 "\t<upstream>3.141592</upstream>\n" &
53 "\t<verdict>pass</verdict>\n" &
57 const universal charstring exer_everything :=
59 " bitstr='00110011' booool='true' cartoon='betty' hexen='235' wholenum='42'" &
61 " octets='DEADBEEF' printer='All your base are belong to us'" &
62 " intl='Aren_zael the master " & eacute & "s t" & aacute & "rsai'" &
63 " upstream='3.141592' verdict='pass'/>" &
66 const universal charstring xer_everything2 :=
68 "\t<bitstr>00110011</bitstr>\n" &
69 "\t<booool><true/></booool>\n" &
71 "\t<cartoon><betty/></cartoon>\n" &
73 "\t<hexen>235</hexen>\n" &
74 "\t<wholenum>42</wholenum>\n" &
75 "\t<octets>DEADBEEF</octets>\n" &
76 "\t<printer>All your base are belong to us</printer>\n" &
77 "\t<intl>Aren_zael the master " & eacute & "s t" & aacute & "rsai</intl>\n" &
78 "\t<upstream>3.141592</upstream>\n" &
79 "\t<verdict>pass</verdict>\n" &
81 "\t<content>And now a word from our sponsors</content>\n" &
85 const universal charstring exer_everything2 :=
87 " bitstr='00110011' booool='true' cartoon='betty' hexen='235' wholenum='42'" &
89 " octets='DEADBEEF' printer='All your base are belong to us'" &
90 " intl='Aren_zael the master " & eacute & "s t" & aacute & "rsai'" &
91 " upstream='3.141592' verdict='pass'>\n" &
92 "\t<content>And now a word from our sponsors</content>\n" &
95 DECLARE_EXER_ENCODERS(Everything, ev);
96 DECLARE_XER_ENCODERS(Everything, ev);
98 testcase encode_everything() runs on fumes
100 var Everything input := ev;
102 CHECK_METHOD(exer_enc_ev, input, exer_everything);
103 CHECK_METHOD(bxer_enc_ev, input, xer_everything);
105 input.content := "And now a word from our sponsors";
106 CHECK_METHOD(exer_enc_ev, input, exer_everything2);
107 CHECK_METHOD(bxer_enc_ev, input, xer_everything2);
110 testcase decode_everything() runs on fumes
112 var Everything output := ev;
114 CHECK_DECODE(exer_dec_ev, exer_everything, Everything, output);
115 CHECK_DECODE(bxer_dec_ev, xer_everything, Everything, output);
117 output.content := "And now a word from our sponsors";
118 CHECK_DECODE(bxer_dec_ev, xer_everything2 , Everything, output);
119 CHECK_DECODE(exer_dec_ev, exer_everything2, Everything, output);
122 /**********************************************************************/
124 DECLARE_XER_ENCODERS(l_source, lsource)
125 DECLARE_EXER_ENCODERS(l_source, lsource)
127 // an embed of one with two attributes
128 const l_source nothing := {
134 const universal charstring bxer_nothing :=
137 "\t\t<UNIVERSAL_CHARSTRING>none</UNIVERSAL_CHARSTRING>\n" &
141 const universal charstring exer_nothing :=
147 const l_source lang := {
153 const universal charstring bxer_lang :=
156 "\t\t<UNIVERSAL_CHARSTRING>lang</UNIVERSAL_CHARSTRING>\n" &
158 "\t<lang>fra</lang>\n" &
161 const universal charstring exer_lang :=
162 "<l_source lang=\'fra\'>" &
166 const l_source wasei := {
167 embed := { "wasei" },
172 const universal charstring bxer_wasei :=
175 "\t\t<UNIVERSAL_CHARSTRING>wasei</UNIVERSAL_CHARSTRING>\n" &
177 "\t<wasei>hai</wasei>\n" &
180 const universal charstring exer_wasei :=
181 "<l_source wasei=\'hai\'>" &
186 const l_source both := {
192 const universal charstring bxer_both :=
195 "\t\t<UNIVERSAL_CHARSTRING>both</UNIVERSAL_CHARSTRING>\n" &
197 "\t<lang>kor</lang>\n" &
198 "\t<wasei>blimey</wasei>\n" &
201 const universal charstring exer_both :=
202 "<l_source lang=\'kor\' wasei=\'blimey\'>" &
208 testcase encode_lsource() runs on fumes
210 CHECK_METHOD(bxer_enc_lsource, nothing, bxer_nothing);
211 CHECK_METHOD(exer_enc_lsource, nothing, exer_nothing);
213 CHECK_METHOD(bxer_enc_lsource, lang, bxer_lang);
214 CHECK_METHOD(exer_enc_lsource, lang, exer_lang);
216 CHECK_METHOD(bxer_enc_lsource, wasei, bxer_wasei);
217 CHECK_METHOD(exer_enc_lsource, wasei, exer_wasei);
219 CHECK_METHOD(bxer_enc_lsource, both, bxer_both);
220 CHECK_METHOD(exer_enc_lsource, both, exer_both);
224 testcase decode_lsource() runs on fumes
226 CHECK_DECODE(bxer_dec_lsource, bxer_nothing, l_source, nothing);
227 CHECK_DECODE(exer_dec_lsource, exer_nothing, l_source, nothing);
229 CHECK_DECODE(bxer_dec_lsource, bxer_lang, l_source, lang);
230 CHECK_DECODE(exer_dec_lsource, exer_lang, l_source, lang);
232 CHECK_DECODE(bxer_dec_lsource, bxer_wasei, l_source, wasei);
233 CHECK_DECODE(exer_dec_lsource, exer_wasei, l_source, wasei);
235 CHECK_DECODE(bxer_dec_lsource, bxer_both, l_source, both);
236 CHECK_DECODE(exer_dec_lsource, exer_both, l_source, both);
239 /**********************************************************************/
242 execute(encode_everything());
243 execute(decode_everything());
245 execute(encode_lsource());
246 execute(decode_lsource());