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 ******************************************************************************/
10 modulepar boolean Txernested_verbose := false;
11 #define verbose Txernested_verbose
12 #include "../macros.ttcnin"
14 external function flatten(inout universal charstring par) ;
16 import from Asntypes all;
17 import from AsnValues all;
25 } nestor; // TTCNv3 equivalent of Nestor
27 // SEQ OF SET OF SEQ OF SET OF SEQUENCE {
28 type record of set of record of set of record {
29 // your CHOICE { only REAL } OPTIONAL
30 union { float only } your optional
34 type record nested_inner {
42 const nested_inner ni := {
47 const nested_inner eki_eki :=
50 { ts1 := 17, ts2 := true }
61 type component Tnested {}
63 DECLARE_XER_ENCODERS(nestor, nst);
64 DECLARE_EXER_ENCODERS(nestor, nst)
65 DECLARE_XER_ENCODERS(Nestor, Nst);
66 DECLARE_EXER_ENCODERS(Nestor, Nst)
67 DECLARE_XER_ENCODERS(NestorEx, Nstx);
68 DECLARE_EXER_ENCODERS(NestorEx, Nstx)
70 //const charstring oftype := "oftype";
72 const deep d_empty := {{{{}}}}
73 const Deep D_empty := {{{{}}}}
74 const nestor n_empty := {
79 const charstring s_empty := "<nestor/>\n\n";
81 const charstring s_2 :=
88 const charstring s_3 :=
104 "\t\t\t\t<SEQUENCE_OF/>\n" &
105 "\t\t\t</SET_OF>\n" &
111 /////////////////////////////////////////////////////////////////////
112 testcase encode_nest() runs on Tnested {
113 var universal charstring expected := s_empty;
114 CHECK_METHOD(bxer_enc_nst, n_empty, expected);
115 CHECK_METHOD(exer_enc_nst, n_empty, expected);
117 CHECK_METHOD(cxer_enc_nst, n_empty, expected & lf);
120 CHECK_METHOD(bxer_enc_nst, n2, expected);
121 CHECK_METHOD(exer_enc_nst, n2, expected);
123 CHECK_METHOD(cxer_enc_nst, n2, expected & lf);
126 CHECK_METHOD(bxer_enc_nst, n3, expected);
127 CHECK_METHOD(exer_enc_nst, n3, expected);
129 CHECK_METHOD(cxer_enc_nst, n3, expected & lf);
132 testcase decode_nest() runs on Tnested {
136 CHECK_DECODE2(nst, s_empty, nestor, expected);
139 CHECK_DECODE2(nst, s_2, nestor, expected);
142 CHECK_DECODE2(nst, s_3, nestor, expected);
145 /////////////////////////////////////////////////////////////////////
147 const charstring nstr_nixtor :=
150 "\t\t<name>nixtor</name>\n" &
155 const charstring nstr_nixtor2 :=
158 "\t\t<name>nixtor2</name>\n" &
160 "\t\t\t<SET_OF/>\n" &
165 const charstring nstr_nixtor3 :=
168 "\t\t<name>nixtor3</name>\n" &
171 "\t\t\t\t<SEQUENCE_OF/>\n" &
172 "\t\t\t</SET_OF>\n" &
177 const charstring nstr_nixtor4 :=
180 "\t\t<name>nixtor4</name>\n" &
183 "\t\t\t\t<SEQUENCE_OF/>\n" &
184 "\t\t\t</SET_OF>\n" &
189 const charstring nstr_an3 :=
192 "\t\t<name>an3[0]</name>\n" &
196 "\t\t<name>an3[1]</name>\n" &
198 "\t\t\t<SET_OF/>\n" &
202 "\t\t<name>an3[2]</name>\n" &
205 "\t\t\t\t<SEQUENCE_OF/>\n" &
206 "\t\t\t</SET_OF>\n" &
211 const charstring nstr_nn :=
214 "\t\t<name>nn</name>\n" &
216 "\t\t\t<ts1>10</ts1>\n" &
217 "\t\t\t<ts2><true/></ts2>\n" &
221 "\t\t\t\t<SEQUENCE_OF>\n" &
222 "\t\t\t\t\t<SET_OF>\n" &
223 "\t\t\t\t\t\t<SEQUENCE>\n" &
224 "\t\t\t\t\t\t\t<your>\n" &
225 "\t\t\t\t\t\t\t\t<only>5.000000</only>\n" &
226 "\t\t\t\t\t\t\t</your>\n" &
227 "\t\t\t\t\t\t</SEQUENCE>\n" &
228 "\t\t\t\t\t</SET_OF>\n" &
229 "\t\t\t\t</SEQUENCE_OF>\n" &
230 "\t\t\t</SET_OF>\n" &
235 const charstring nstrx_nixtorex :=
238 "\t\t<name>nixtorex</name>\n" &
243 const charstring nstrx_nixtor2ex :=
246 "\t\t<name>nixtor2ex</name>\n" &
248 "\t\t\t<Deep4o/>\n" &
253 const charstring nstrx_nixtor3ex :=
256 "\t\t<name>nixtor3ex</name>\n" &
259 "\t\t\t\t<Deep3o/>\n" &
260 "\t\t\t</Deep4o>\n" &
265 const charstring nstrx_nixtor4ex :=
268 "\t\t<name>nixtor4ex</name>\n" &
271 "\t\t\t\t<Deep3o/>\n" &
272 "\t\t\t</Deep4o>\n" &
277 const charstring nstrx_an3ex :=
280 "\t\t<name>an3ex[0]</name>\n" &
284 "\t\t<name>an3ex[1]</name>\n" &
286 "\t\t\t<Deep4o/>\n" &
290 "\t\t<name>an3ex[2]</name>\n" &
293 "\t\t\t\t<Deep3o/>\n" &
294 "\t\t\t</Deep4o>\n" &
299 const charstring nstrx_nnx :=
302 "\t\t<name>nnx</name>\n" &
304 "\t\t\t<ts1>10</ts1>\n" &
305 "\t\t\t<ts2><true/></ts2>\n" &
309 "\t\t\t\t<Deep3o>\n" &
310 "\t\t\t\t\t<Deep2o>\n" &
311 "\t\t\t\t\t\t<Deep1s>\n" &
312 "\t\t\t\t\t\t\t<your>\n" &
313 "\t\t\t\t\t\t\t\t<only>5.000000</only>\n" &
314 "\t\t\t\t\t\t\t</your>\n" &
315 "\t\t\t\t\t\t</Deep1s>\n" &
316 "\t\t\t\t\t</Deep2o>\n" &
317 "\t\t\t\t</Deep3o>\n" &
318 "\t\t\t</Deep4o>\n" &
323 testcase encode_nest_asn() runs on Tnested
325 var universal charstring expected;
327 expected := nstr_nixtor;
328 CHECK_METHOD(bxer_enc_Nst, AsnValues.nixtor, expected);
330 CHECK_METHOD(cxer_enc_Nst, AsnValues.nixtor, expected & lf);
332 expected := nstr_nixtor2;
333 CHECK_METHOD(bxer_enc_Nst, AsnValues.nixtor2, expected);
335 CHECK_METHOD(cxer_enc_Nst, AsnValues.nixtor2, expected & lf);
337 expected := nstr_nixtor3;
338 CHECK_METHOD(bxer_enc_Nst, AsnValues.nixtor3, expected);
340 CHECK_METHOD(cxer_enc_Nst, AsnValues.nixtor3, expected & lf);
342 expected := nstr_nixtor4;
343 CHECK_METHOD(bxer_enc_Nst, AsnValues.nixtor4, expected);
345 CHECK_METHOD(cxer_enc_Nst, AsnValues.nixtor4, expected & lf);
347 expected := nstr_an3;
348 CHECK_METHOD(bxer_enc_Nst, AsnValues.an3, expected);
350 CHECK_METHOD(cxer_enc_Nst, AsnValues.an3, expected & lf);
353 CHECK_METHOD(bxer_enc_Nst, AsnValues.nn, expected);
355 CHECK_METHOD(cxer_enc_Nst, AsnValues.nn, expected & lf);
357 expected := nstr_an3;
358 CHECK_METHOD(bxer_enc_Nst, AsnValues.an3, expected);
360 CHECK_METHOD(cxer_enc_Nst, AsnValues.an3, expected & lf);
362 /*******************************************************************/
364 expected := nstrx_nixtorex;
365 CHECK_METHOD(bxer_enc_Nstx, AsnValues.nixtorex, expected);
367 CHECK_METHOD(cxer_enc_Nstx, AsnValues.nixtorex, expected & lf);
369 expected := nstrx_nixtor2ex;
370 CHECK_METHOD(bxer_enc_Nstx, AsnValues.nixtor2ex, expected);
372 CHECK_METHOD(cxer_enc_Nstx, AsnValues.nixtor2ex, expected & lf);
374 expected := nstrx_nixtor3ex;
375 CHECK_METHOD(bxer_enc_Nstx, AsnValues.nixtor3ex, expected);
377 CHECK_METHOD(cxer_enc_Nstx, AsnValues.nixtor3ex, expected & lf);
379 expected := nstrx_nixtor4ex;
380 CHECK_METHOD(bxer_enc_Nstx, AsnValues.nixtor4ex, expected);
382 CHECK_METHOD(cxer_enc_Nstx, AsnValues.nixtor4ex, expected & lf);
384 expected := nstrx_an3ex;
385 CHECK_METHOD(bxer_enc_Nstx, AsnValues.an3ex, expected);
387 CHECK_METHOD(cxer_enc_Nstx, AsnValues.an3ex, expected & lf);
389 expected := nstrx_nnx;
390 CHECK_METHOD(bxer_enc_Nstx, AsnValues.nnx, expected);
392 CHECK_METHOD(cxer_enc_Nstx, AsnValues.nnx, expected & lf);
396 /********* infinite recursion in record-of is OK *********/
397 type record of Inf Inf;
398 DECLARE_XER_ENCODERS(Inf, inf);
399 DECLARE_EXER_ENCODERS(Inf, inf);
401 const Inf empty := {}
402 const Inf level3 := {{{}}}
404 const universal charstring str_empty := "<Inf/>\n\n";
405 const universal charstring str3 :=
412 const universal charstring str3empty :=
420 testcase encode_inf() runs on Tnested
422 var universal charstring expected;
424 expected := str_empty;
425 CHECK_METHOD(bxer_enc_inf, empty, expected);
426 CHECK_METHOD(exer_enc_inf, empty, expected);
428 CHECK_METHOD(cxer_enc_inf, empty, expected & lf);
430 expected := str3empty;
431 CHECK_METHOD(bxer_enc_inf, level3, expected);
432 CHECK_METHOD(exer_enc_inf, level3, expected);
434 CHECK_METHOD(cxer_enc_inf, level3, expected & lf);
437 testcase decode_inf() runs on Tnested
439 CHECK_DECODE2( inf, str_empty, Inf, empty);
440 CHECK_DECODE(exer_dec_inf, str_empty, Inf, empty);
442 CHECK_DECODE2( inf, str3empty, Inf, level3);
443 CHECK_DECODE(exer_dec_inf, str3empty, Inf, level3);
445 // also check that non-empty element can be decoded
446 CHECK_DECODE2( inf, str3 , Inf, level3);
447 CHECK_DECODE(exer_dec_inf, str3 , Inf, level3);
451 execute(encode_nest());
452 execute(encode_nest_asn());
453 execute(decode_nest());
455 execute(encode_inf());
456 execute(decode_inf());
462 extension "version R8N";