From c15fc23cb62a3405f93ef0a2482c1d5bd8995599 Mon Sep 17 00:00:00 2001 From: Botond Baranyi <botond.baranyi@ericsson.com> Date: Wed, 16 May 2018 17:07:02 +0200 Subject: [PATCH] Fixed OER decoding of missing default fields in RT2 (bug 534769) Change-Id: I3643492d8df2ac997707983c0a81909f38fa9ed7 Signed-off-by: Botond Baranyi <botond.baranyi@ericsson.com> --- core2/Basetype2.cc | 4 +++- regression_test/OER/OER.ttcn | 15 +++++++++++++++ regression_test/OER/Types.asn | 6 ++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/core2/Basetype2.cc b/core2/Basetype2.cc index ae2f92199..231fbee13 100644 --- a/core2/Basetype2.cc +++ b/core2/Basetype2.cc @@ -6814,7 +6814,9 @@ int Record_Type::OER_decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_bu } if (get_at(p_td.oer->p[i])->is_optional() || is_default_field) { if (!(uc[0] & 1 << (7-act_pos))) { - get_at(p_td.oer->p[i])->set_to_omit(); + if (get_at(p_td.oer->p[i])->is_optional()) { + get_at(p_td.oer->p[i])->set_to_omit(); + } } else { get_at(p_td.oer->p[i])->OER_decode(*fld_descr(p_td.oer->p[i]), p_buf, p_oer); } diff --git a/regression_test/OER/OER.ttcn b/regression_test/OER/OER.ttcn index 9cba67b5d..531ca79c3 100644 --- a/regression_test/OER/OER.ttcn +++ b/regression_test/OER/OER.ttcn @@ -3571,6 +3571,20 @@ } setverdict(pass); } + + external function dec_RecWithDefault(in octetstring stream) return RecWithDefault + with { extension "prototype (convert) decode(OER)" } + + // Testing the decoding of a field with a default value (bug 534769) + testcase tc_default() runs on EmptyCT { + var octetstring enc := '000104'O; + var RecWithDefault dec := dec_RecWithDefault(enc); + var RecWithDefault dec_exp := { field2 := 4 }; // the default value is currently not set, the field remains unbound, but there should be no DTE + if (log2str(dec) != log2str(dec_exp)) { + setverdict(fail, "Decoding failed. Got: ", dec, ", expected: ", dec_exp); + } + setverdict(pass); + } control { execute(tc_boolean()); @@ -3593,6 +3607,7 @@ execute(tc_example()); execute(tc_529017()); execute(tc_533061()); + execute(tc_default()); } } diff --git a/regression_test/OER/Types.asn b/regression_test/OER/Types.asn index a15619d2b..99f60ef03 100644 --- a/regression_test/OER/Types.asn +++ b/regression_test/OER/Types.asn @@ -543,5 +543,11 @@ Rec533061 ::= SEQUENCE field-ext2 REAL OPTIONAL } +RecWithDefault ::= SEQUENCE +{ + field1 INTEGER DEFAULT 1, + field2 INTEGER +} + END -- GitLab