/****************************************************************************** * Copyright (c) 2000-2016 Ericsson Telecom AB * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors: * Balasko, Jeno * Raduly, Csaba * ******************************************************************************/ module AnyStuff { import from Flattener { function all } modulepar boolean AnyStuff_verbose := false; #define verbose AnyStuff_verbose #include "../macros.ttcnin" type component Anything {} type record AnyElem { universal charstring Html, integer num } with { variant (Html) "anyElement" } type record UnivAnyElem { universal charstring Html, integer num } with { variant (Html) "anyElement" } type record AnyElemList { record of universal charstring elem_list , integer f1 optional , charstring f2 optional } with { variant (elem_list) "anyElement" // perhaps this should now be variant (elem_list[-]) } DECLARE_XER_ENCODERS(AnyElem, ae); DECLARE_EXER_ENCODERS(AnyElem, ae); DECLARE_XER_ENCODERS(UnivAnyElem, uae); DECLARE_EXER_ENCODERS(UnivAnyElem, uae); DECLARE_XER_ENCODERS(AnyElemList, anyt); DECLARE_EXER_ENCODERS(AnyElemList, anyt); const AnyElem ae1 := { "Hellonobody", 42 } const UnivAnyElem uae1 := { "Hellonobody", 42 } const AnyElemList aybabtu := { { "", "", "", "", "" } , omit, omit } const AnyElemList aybabtu_expect := { { "", "", "", "", "" } , omit, omit } const universal charstring ae1str := "\n" & "\tHellonobody\n" & "\t42\n" & "\n\n"; const universal charstring ae1strb := // for Basic XER "\n" & "\t<html><head><title>Hello</title></head><body>nobody</body></html>\n" & "\t42\n" & "\n\n"; const universal charstring uae1str := "\n" & "\tHellonobody\n" & "\t42\n" & "\n\n"; const universal charstring uae1strb := // for Basic XER "\n" & "\t<html><head><title>Hello</title></head><body>nobody</body></html>\n" & "\t42\n" & "\n\n"; const universal charstring aybabtustr := "\n" & "\t\n" & "\t\n" & "\t\n" & "\t\n" & "\t\n" & "\n\n"; const universal charstring aybabtustr_b := "\n" & "\t\n" & "\t\t<all/>\n" & "\t\t<your/>\n" & "\t\t<base/>\n" & "\t\t<are/>\n" & "\t\t<belong to='us'/>\n" & "\t\n" & "\n\n"; testcase enc_anyelement() runs on Anything { CHECK_METHOD(bxer_enc_ae, ae1, ae1strb); CHECK_METHOD(exer_enc_ae, ae1, ae1str); CHECK_METHOD(bxer_enc_uae, uae1, uae1strb); CHECK_METHOD(exer_enc_uae, uae1, uae1str); CHECK_METHOD(bxer_enc_anyt, aybabtu, aybabtustr_b); CHECK_METHOD(exer_enc_anyt, aybabtu, aybabtustr); } testcase dec_anyelement() runs on Anything { CHECK_DECODE(bxer_dec_ae, ae1strb, AnyElem, ae1); CHECK_DECODE(exer_dec_ae, ae1str , AnyElem, ae1); CHECK_DECODE(exer_dec_ae, flatten(ae1str), AnyElem, ae1); CHECK_DECODE(bxer_dec_uae, uae1strb, UnivAnyElem, uae1); CHECK_DECODE(exer_dec_uae, uae1str , UnivAnyElem, uae1); CHECK_DECODE(exer_dec_uae, flatten(uae1str), UnivAnyElem, uae1); var AnyElemList expected := aybabtu; CHECK_DECODE(bxer_dec_anyt, aybabtustr_b, AnyElemList, expected); //No, it should NOT do this: expected.elem_list := {} //This is not an EMBED-VALUES! expected := aybabtu_expect; CHECK_DECODE(exer_dec_anyt, aybabtustr, AnyElemList, expected); CHECK_DECODE(exer_dec_anyt, flatten(aybabtustr), AnyElemList, expected); } control { execute(enc_anyelement()); execute(dec_anyelement()); } } with { encode "XML" }