Last sync 2016.04.01
[deliverable/titan.core.git] / regression_test / XML / HU13380 / HU13380.ttcn
1 /******************************************************************************
2 * Copyright (c) 2000-2016 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 *
8 * Contributors:
9 * Balasko, Jeno
10 * Baranyi, Botond
11 *
12 ******************************************************************************/
13
14 // Original TR:
15 // Omitted optional fields of union type (with the "untagged" coding instruction)
16 // are not handled by the XER decoder.
17 // The XER decoder reports a decoding error, if the decoded element does not match
18 // any of the union's alternatives. It does not consider the possibility, that the
19 // union might be an (omitted) optional field of a record or set, and decoded
20 // element might be meant for another field.
21 module HU13380 {
22
23 type component CT {}
24
25 type record Rec {
26 integer int1,
27 union {
28 charstring abc,
29 charstring def
30 } uni optional,
31 integer int2
32 }
33 with {
34 variant(uni) "untagged";
35 }
36
37 external function f_enc(in Rec x) return octetstring
38 with { extension "prototype(convert) encode(XER:XER_EXTENDED)" }
39
40 external function f_dec(in octetstring x) return Rec
41 with { extension "prototype(convert) decode(XER:XER_EXTENDED)" }
42
43 const Rec c_value := { 3, omit, -3 };
44 const octetstring c_value_enc := char2oct(
45 "<Rec>\n" &
46 "\t<int1>3</int1>\n" &
47 "\t<int2>-3</int2>\n" &
48 "</Rec>\n\n");
49
50 testcase tc_HU13380() runs on CT {
51 var octetstring v_enc := f_enc(c_value);
52 if (v_enc != c_value_enc) {
53 setverdict(fail, "Expected: ", c_value_enc, ", got: ", v_enc);
54 }
55 var Rec v_dec := f_dec(c_value_enc);
56 if (v_dec != c_value) {
57 setverdict(fail, "Expected: ", c_value, ", got: ", v_dec);
58 }
59 setverdict(pass);
60 }
61
62 control {
63 execute(tc_HU13380());
64 }
65
66 }
67 with {
68 encode "XML";
69 }
This page took 0.086594 seconds and 5 git commands to generate.