Commit 791f5ea9 authored by Botond Baranyi's avatar Botond Baranyi
Browse files

OER dec: optional fields after the extension are now set to omit if the...


OER dec: optional fields after the extension are now set to omit if the extension bit is unset (bug 533061)

Change-Id: If91e57c1429ddb369e358c576ede91b070691630
Signed-off-by: Botond Baranyi's avatarBotond Baranyi <botond.baranyi@ericsson.com>
parent 78a82971
......@@ -4992,6 +4992,7 @@ void defRecordClass1(const struct_def *sdef, output_struct *output)
int eag_pos = 0;
pos = 8;
ind = 0;
boolean has_optional_in_extension = FALSE;
for (i = limit; i < sdef->nElements; i++) {
pos--;
src = mputprintf(src,
......@@ -5001,6 +5002,7 @@ void defRecordClass1(const struct_def *sdef, output_struct *output)
eag_pos++;
for (int j = i; j < limit + sdef->oerEag[eag_pos]; j++) {
if (sdef->elements[sdef->oerP[j]].isOptional) {
has_optional_in_extension = TRUE;
src = mputprintf(src,
" field_%s = OMIT_VALUE;\n"
, sdef->elements[sdef->oerP[j]].name);
......@@ -5009,6 +5011,7 @@ void defRecordClass1(const struct_def *sdef, output_struct *output)
eag_pos--;
} else {
if (sdef->elements[sdef->oerP[i]].isOptional) {
has_optional_in_extension = TRUE;
src = mputprintf(src,
" field_%s = OMIT_VALUE;\n"
, sdef->elements[i].name);
......@@ -5071,6 +5074,18 @@ void defRecordClass1(const struct_def *sdef, output_struct *output)
ind++;
}
}
if (has_optional_in_extension) {
src = mputstr(src,
" }\n"
" else {\n");
for (i = limit; i < sdef->nElements; i++) {
if (sdef->elements[sdef->oerP[i]].isOptional) {
src = mputprintf(src,
" field_%s = OMIT_VALUE;\n"
, sdef->elements[i].name);
}
}
}
src = mputstr(src,
" }\n");
}
......
......@@ -6927,6 +6927,14 @@ int Record_Type::OER_decode(const TTCN_Typedescriptor_t& p_td, TTCN_Buffer& p_bu
}
}
}
else if (p_td.oer->extendable) {
// Set the optional fields after the extension to 'omit'
for (int i = limit; i < field_count; ++i) {
if (get_at(p_td.oer->p[i])->is_optional()) {
get_at(p_td.oer->p[i])->set_to_omit();
}
}
}
if (is_opentype_outermost()) {
TTCN_EncDec_ErrorContext ec_1("While decoding opentypes: ");
......
......@@ -2291,7 +2291,11 @@
me := 1,
me2 := 2,
me3 := omit,
me4 := 4
me4 := 4,
f2 := omit,
f4 := omit,
f5 := omit,
f7 := omit
}
os := enc_ExtensionRecord2(er2);
if (os != '40010101020104'O) {
......@@ -2677,7 +2681,16 @@
if (os != '400101'O) {
setverdict(fail, "tc_sequence: ", match('400101'O, os));
}
erres71 := { me := 1 }
erres71 := {
me := 1,
f2 := omit,
f4 := omit,
f5 := omit,
f6 := omit,
f7 := omit,
f9 := omit,
f_nul := omit
}
erres7 := dec_ExtensionRecord5(os);
if (not(match(log2str(erres7), log2str(erres71)))) {
setverdict(fail, "tc_sequence: ", match(log2str(erres7), log2str(erres71)));
......@@ -3544,6 +3557,20 @@
}
setverdict(pass);
}
external function dec_Rec533061(in octetstring stream) return Rec533061
with { extension "prototype (convert) decode(OER)" }
// Testing the fixes to decoding extended records made for bug 533061
testcase tc_533061() runs on EmptyCT {
var octetstring enc := '4001010102'O;
var Rec533061 dec := dec_Rec533061(enc);
var Rec533061 dec_exp := { field1 := 1, field2 := 2, field_ext1 := omit, field_ext2 := omit };
if (dec != dec_exp) {
setverdict(fail, "Decoding failed. Got: ", dec, ", expected: ", dec_exp);
}
setverdict(pass);
}
control {
execute(tc_boolean());
......@@ -3565,6 +3592,7 @@
execute(tc_opentype());
execute(tc_example());
execute(tc_529017());
execute(tc_533061());
}
}
......@@ -534,7 +534,14 @@ Enum529017 ::= ENUMERATED
val1
}
Rec533061 ::= SEQUENCE
{
field1 INTEGER,
field2 INTEGER OPTIONAL,
...,
field-ext1 INTEGER OPTIONAL,
field-ext2 REAL OPTIONAL
}
END
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment