1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
/******************************************************************************
* 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 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 :=
"<choose1>\n" &
"\t<f1>42</f1>\n" &
"</choose1>\n\n";
const universal charstring str_alt2 :=
"<choose1>\n" &
"\t<f2>true</f2>\n" &
"\t<f2>true</f2>\n" &
"\t<f2>false</f2>\n" &
"</choose1>\n\n";
const universal charstring str_alt20 :=
"<choose1>\n" &
"</choose1>\n\n";
const universal charstring str_alt21 :=
"<choose1/>\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";
}
|