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 ******************************************************************************/
9 modulepar boolean Marx_verbose := false;
10 #define verbose Marx_verbose
11 #include "../macros.ttcnin"
17 //type enumerated Marxes { chico, groucho, harpo };
19 type record Brothers {
20 record of enumerated { chico,groucho,harpo } order,
29 DECLARE_XER_ENCODERS(Brothers, marx);
30 DECLARE_EXER_ENCODERS(Brothers, marx);
33 type component Paramount {}
35 const universal charstring str_grimm_b :=
38 "\t\t<chico/><groucho/><harpo/>\n" &
40 "\t<chico>17</chico>\n" &
41 "\t<groucho>Je suis Marxiste, tendance Groucho</groucho>\n" &
46 const universal charstring str_grimm_e :=
48 "\t<chico>17</chico>\n" &
49 "\t<groucho>Je suis Marxiste, tendance Groucho</groucho>\n" &
54 const universal charstring str_grimm_b2 :=
57 "\t\t<groucho/><harpo/><chico/>\n" &
59 "\t<chico>17</chico>\n" &
60 "\t<groucho>Je suis Marxiste, tendance Groucho</groucho>\n" &
65 const universal charstring str_grimm_e2 :=
67 "\t<groucho>Je suis Marxiste, tendance Groucho</groucho>\n" &
69 "\t<chico>17</chico>\n" &
73 testcase duck_soup () runs on Paramount
75 var Brothers grimm := {
76 { chico, groucho, harpo },
77 17, "Je suis Marxiste, tendance Groucho", {}
79 CHECK_METHOD(bxer_enc_marx, grimm, str_grimm_b);
80 CHECK_METHOD(exer_enc_marx, grimm, str_grimm_e);
82 grimm.order := { groucho, harpo, chico };
84 CHECK_METHOD(bxer_enc_marx, grimm, str_grimm_b2);
85 CHECK_METHOD(exer_enc_marx, grimm, str_grimm_e2);
88 testcase a_night_at_the_opera () runs on MGM
90 var Brothers grimm := {
91 { chico, groucho, harpo },
92 17, "Je suis Marxiste, tendance Groucho", {}
94 CHECK_DECODE(bxer_dec_marx, str_grimm_b, Brothers, grimm);
95 CHECK_DECODE(exer_dec_marx, str_grimm_e, Brothers, grimm);
98 /* * * * * * * * * * * * * * */
100 type record Stooges {
101 record of universal charstring emb,
102 record of enumerated { curly, larry, moe } ord,
109 variant "embedValues";
112 DECLARE_XER_ENCODERS (Stooges, st3);
113 DECLARE_EXER_ENCODERS(Stooges, st3);
115 const universal charstring str_stg_b :=
119 "\t\t<UNIVERSAL_CHARSTRING/>\n" &
120 "\t\t<UNIVERSAL_CHARSTRING>. is curly</UNIVERSAL_CHARSTRING>\n" &
121 "\t\t<UNIVERSAL_CHARSTRING>.. is bald</UNIVERSAL_CHARSTRING>\n" &
122 "\t\t<UNIVERSAL_CHARSTRING>...is tall</UNIVERSAL_CHARSTRING>\n" &
126 "\t\t<larry/><curly/><moe/>\n" &
128 "\t<curly>13</curly>\n" &
129 "\t<larry>1.414213</larry>\n" &
130 "\t<moe><true/></moe>\n" &
134 const universal charstring str_stg_e :=
136 "" & // the first embedded string (empty in this case)
137 "<larry>1.414213</larry>" &
138 ". is curly" & // the embedded strings are not affected by USE-ORDER
139 "<curly>13</curly>" &
147 const Stooges s3 := {
148 emb := {"",". is curly",".. is bald","...is tall"},
149 ord := { larry, curly, moe },
155 testcase beer_and_pretzels() runs on MGM
157 CHECK_METHOD(bxer_enc_st3, s3, str_stg_b);
158 CHECK_METHOD(exer_enc_st3, s3, str_stg_e);
161 testcase plane_nuts() runs on MGM
163 var Stooges expected := s3;
164 CHECK_DECODE(bxer_dec_st3, str_stg_b, Stooges, expected);
165 CHECK_DECODE(exer_dec_st3, str_stg_e, Stooges, expected);
169 execute(duck_soup()); // encoding use-order
170 execute(a_night_at_the_opera()); // decode ===//===
171 execute(beer_and_pretzels()); // encoding use-order + embed-values
172 execute(plane_nuts()); // decode ===//=== ===//===