/****************************************************************************** * Copyright (c) 2000-2015 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 ******************************************************************************/ module Regressions { modulepar boolean Regressions_verbose := false; #define verbose Regressions_verbose #include "../macros.ttcnin" //import from EmbedValues { const LF }; //import from Flattener { function flatten } type union choose1 { integer f1, record of boolean f2_list } with { variant (f2_list) "untagged"; variant (f2_list[-]) "name as 'f2' "; variant "element"; } DECLARE_EXER_ENCODERS(choose1, cx); const choose1 alt1 := { f1 := 42 }; const choose1 alt20:= { f2_list := {} }; const choose1 alt2 := { f2_list := { true,true,false } }; const universal charstring str_alt1 := "\n" & "\t42\n" & "\n\n"; const universal charstring str_alt2 := "\n" & "\ttrue\n" & "\ttrue\n" & "\tfalse\n" & "\n\n"; const universal charstring str_alt20 := "\n" & "\n\n"; const universal charstring str_alt21 := "\n\n"; type component C {} testcase tc_enc_choice() runs on C { CHECK_METHOD(exer_enc_cx, alt1, str_alt1); CHECK_METHOD(exer_enc_cx, alt2, str_alt2); CHECK_METHOD(exer_enc_cx, alt20,str_alt20); } testcase tc_dec_choice() runs on C { CHECK_DECODE(exer_dec_cx, str_alt1, choose1, alt1); CHECK_DECODE(exer_dec_cx, str_alt2, choose1, alt2); CHECK_DECODE(exer_dec_cx, str_alt20, choose1, alt20); CHECK_DECODE(exer_dec_cx, str_alt21, choose1, alt20); } control { execute(tc_enc_choice()); execute(tc_dec_choice()); } } with { encode "XML"; }