Commit | Line | Data |
---|---|---|
970ed795 | 1 | /****************************************************************************** |
3abe9331 | 2 | * Copyright (c) 2000-2015 Ericsson Telecom AB |
970ed795 EL |
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 | ******************************************************************************/ | |
8 | module Regressions { | |
9 | modulepar boolean Regressions_verbose := false; | |
10 | #define verbose Regressions_verbose | |
11 | #include "../macros.ttcnin" | |
12 | ||
13 | //import from EmbedValues { const LF }; | |
14 | //import from Flattener { function flatten } | |
15 | ||
16 | type union choose1 { | |
17 | integer f1, | |
18 | record of boolean f2_list | |
19 | } | |
20 | with { | |
21 | variant (f2_list) "untagged"; | |
22 | variant (f2_list[-]) "name as 'f2' "; | |
23 | variant "element"; | |
24 | } | |
25 | ||
26 | DECLARE_EXER_ENCODERS(choose1, cx); | |
27 | ||
28 | const choose1 alt1 := { f1 := 42 }; | |
29 | const choose1 alt20:= { f2_list := {} }; | |
30 | const choose1 alt2 := { f2_list := { true,true,false } }; | |
31 | ||
32 | const universal charstring str_alt1 := | |
33 | "<choose1>\n" & | |
34 | "\t<f1>42</f1>\n" & | |
35 | "</choose1>\n\n"; | |
36 | ||
37 | const universal charstring str_alt2 := | |
38 | "<choose1>\n" & | |
39 | "\t<f2>true</f2>\n" & | |
40 | "\t<f2>true</f2>\n" & | |
41 | "\t<f2>false</f2>\n" & | |
42 | "</choose1>\n\n"; | |
43 | ||
44 | const universal charstring str_alt20 := | |
45 | "<choose1>\n" & | |
46 | "</choose1>\n\n"; | |
47 | ||
48 | const universal charstring str_alt21 := | |
49 | "<choose1/>\n\n"; | |
50 | ||
51 | ||
52 | type component C {} | |
53 | ||
54 | testcase tc_enc_choice() runs on C | |
55 | { | |
56 | CHECK_METHOD(exer_enc_cx, alt1, str_alt1); | |
57 | CHECK_METHOD(exer_enc_cx, alt2, str_alt2); | |
58 | CHECK_METHOD(exer_enc_cx, alt20,str_alt20); | |
59 | } | |
60 | ||
61 | testcase tc_dec_choice() runs on C | |
62 | { | |
63 | CHECK_DECODE(exer_dec_cx, str_alt1, choose1, alt1); | |
64 | CHECK_DECODE(exer_dec_cx, str_alt2, choose1, alt2); | |
65 | CHECK_DECODE(exer_dec_cx, str_alt20, choose1, alt20); | |
66 | CHECK_DECODE(exer_dec_cx, str_alt21, choose1, alt20); | |
67 | } | |
68 | ||
69 | control { | |
70 | execute(tc_enc_choice()); | |
71 | execute(tc_dec_choice()); | |
72 | } | |
73 | ||
74 | } | |
75 | with { | |
76 | encode "XML"; | |
77 | } |