Commit efc0f62f authored by Botond Baranyi's avatar Botond Baranyi
Browse files

Implemented negative testing for the RAW attribute 'LENGTHTO' (Bug 566562)


Signed-off-by: Botond Baranyi's avatarBotond Baranyi <botond.baranyi@ericsson.com>
Change-Id: Ib1d076ae9cd625f0ec896563826d975c83807f3e
Signed-off-by: Botond Baranyi's avatarBotond Baranyi <botond.baranyi@ericsson.com>
parent decade77
......@@ -1014,40 +1014,63 @@ char *generate_raw_coding_negtest(char *src, const struct_def *sdef,
" if (!is_bound()) TTCN_EncDec_ErrorContext::error"
"(TTCN_EncDec::ET_UNBOUND, \"Encoding an unbound value.\");\n"
" int idx_map[%lu];\n"
" for (int idx_map_idx = 0; idx_map_idx < %lu; ++idx_map_idx)\n"
" int idx_map_before[%lu];\n"
" int idx_map_after[%lu];\n"
" bool altered_[%lu];\n"
" for (int idx_map_idx = 0; idx_map_idx < %lu; ++idx_map_idx) {\n"
" idx_map[idx_map_idx] = -1;\n"
" idx_map_before[idx_map_idx] = -1;\n"
" idx_map_after[idx_map_idx] = -1;\n"
" altered_[idx_map_idx] = false;\n"
" };\n"
" (void)idx_map;\n"
" (void)idx_map_before;\n"
" (void)idx_map_after;\n"
" (void)altered_;\n"
" int encoded_length = 0;\n"
" int num_fields = get_count();\n"
" myleaf.isleaf = FALSE;\n"
" myleaf.body.node.num_of_nodes = 0;\n"
" for (int field_idx = 0; field_idx < num_fields; ++field_idx) {\n"
" if ((p_err_descr->omit_before != -1) &&\n"
" (field_idx < p_err_descr->omit_before))\n"
" (field_idx < p_err_descr->omit_before)) {\n"
" altered_[field_idx] = true;\n"
" continue;\n"
" }\n"
" const Erroneous_values_t *err_vals = p_err_descr->get_field_err_values(field_idx);\n"
" const Erroneous_descriptor_t *emb_descr = p_err_descr->get_field_emb_descr(field_idx);\n"
" if (err_vals && err_vals->before)\n"
" if (err_vals && err_vals->before) {\n"
" idx_map_before[field_idx] = myleaf.body.node.num_of_nodes;\n"
" ++myleaf.body.node.num_of_nodes;\n"
" }\n"
" if (err_vals && err_vals->value) {\n"
" if (err_vals->value->errval) {\n"
" // Field is modified, but it's still there. Otherwise, it's\n"
" // initialized to `-1'.\n"
" idx_map[field_idx] = -2;\n"
" idx_map[field_idx] = myleaf.body.node.num_of_nodes;\n"
" ++myleaf.body.node.num_of_nodes;\n"
" }\n"
" altered_[field_idx] = true;\n"
" } else {\n"
" if (emb_descr) idx_map[field_idx] = -2;\n"
" else idx_map[field_idx] = myleaf.body.node.num_of_nodes;\n"
" if (emb_descr) altered_[field_idx] = true;\n"
" idx_map[field_idx] = myleaf.body.node.num_of_nodes;\n"
" ++myleaf.body.node.num_of_nodes;\n"
" }\n"
" if (err_vals && err_vals->after)\n"
" if (err_vals && err_vals->after) {\n"
" idx_map_after[field_idx] = myleaf.body.node.num_of_nodes;\n"
" ++myleaf.body.node.num_of_nodes;\n"
" }\n"
" if ((p_err_descr->omit_after != -1) &&\n"
" (field_idx >= p_err_descr->omit_after))\n"
" (field_idx >= p_err_descr->omit_after)) {\n"
" ++field_idx;\n"
" while (field_idx < num_fields) {\n"
" altered_[field_idx] = true;\n"
" ++field_idx;\n"
" }\n"
" break;\n"
" }\n"
" }\n",
name, (unsigned long)sdef->nElements, (unsigned long)sdef->nElements);
name, (unsigned long)sdef->nElements, (unsigned long)sdef->nElements,
(unsigned long)sdef->nElements, (unsigned long)sdef->nElements,
(unsigned long)sdef->nElements);
/* Init nodes. */
src = mputprintf(src,
" myleaf.body.node.nodes =\n"
......@@ -1153,7 +1176,7 @@ char *generate_raw_coding_negtest(char *src, const struct_def *sdef,
" in_between_modified = TRUE;\n"
" break;\n"
" }\n"
" if (idx_map[%d] < 0 || idx_map[%d] < 0 ||\n"
" if (altered_[%d] || altered_[%d] ||\n"
" %d != idx_map[%d] - idx_map[%d] || in_between_modified) {\n"
" e_c.set_msg(\"Field #%d and/or #%d: \");\n"
" TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_NEGTEST_CONFL,\n"
......@@ -1203,74 +1226,81 @@ char *generate_raw_coding_negtest(char *src, const struct_def *sdef,
/* Encoding of lenghto fields. */
int a;
src = mputprintf(src,
" if (idx_map[%lu] < 0) {\n"
" e_c.set_msg(\"Field '%s': \");\n"
" TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_NEGTEST_CONFL,\n"
" \"Conflicting negative testing attributes, LENGTHTO "
"attribute will be ignored\");\n"
" } else {\n"
" boolean negtest_confl_lengthto = FALSE;\n",
(unsigned long)i, sdef->elements[i].name);
" if (idx_map[%lu] >= 0 && !altered_[%lu]) {\n"
" size_t nof_fields = %d",
(unsigned long)i, (unsigned long)i, sdef->elements[i].raw.lengthto_num);
for (a = 0; a < sdef->elements[i].raw.lengthto_num; a++) {
src = mputprintf(src,
" if (idx_map[%lu] < 0) {\n"
" negtest_confl_lengthto = TRUE;\n"
" e_c.set_msg(\"Field '%s': \");\n"
" TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_NEGTEST_CONFL,\n"
" \"Conflicting negative testing attributes, LENGTHTO "
"attribute will be ignored\");\n"
" }\n",
" + (idx_map_before[%lu] >= 0) + (idx_map_after[%lu] >= 0)",
(unsigned long)sdef->elements[i].raw.lengthto[a],
sdef->elements[sdef->elements[i].raw.lengthto[a]].name);
(unsigned long)sdef->elements[i].raw.lengthto[a]);
}
src = mputprintf(src,
" if (!negtest_confl_lengthto) {\n"
" encoded_length += %d;\n"
" myleaf.body.node.nodes[idx_map[%lu]]->calc = CALC_LENGTH;\n"
" myleaf.body.node.nodes[idx_map[%lu]]->coding_descr = &%s_descr_;\n"
" myleaf.body.node.nodes[idx_map[%lu]]->calcof.lengthto.num_of_fields = %d;\n"
" myleaf.body.node.nodes[idx_map[%lu]]->calcof.lengthto.unit = %d;\n"
" myleaf.body.node.nodes[idx_map[%lu]]->calcof.lengthto.offset = %d;\n"
" myleaf.body.node.nodes[idx_map[%lu]]->calcof.lengthto.fields = "
"init_lengthto_fields_list(%d);\n"
" myleaf.body.node.nodes[idx_map[%lu]]->length = %d;\n",
";\n"
" encoded_length += %d;\n"
" myleaf.body.node.nodes[idx_map[%lu]]->calc = CALC_LENGTH;\n"
" myleaf.body.node.nodes[idx_map[%lu]]->coding_descr = &%s_descr_;\n"
" myleaf.body.node.nodes[idx_map[%lu]]->calcof.lengthto.num_of_fields = nof_fields;\n"
" myleaf.body.node.nodes[idx_map[%lu]]->calcof.lengthto.unit = %d;\n"
" myleaf.body.node.nodes[idx_map[%lu]]->calcof.lengthto.offset = %d;\n"
" myleaf.body.node.nodes[idx_map[%lu]]->calcof.lengthto.fields = "
"init_lengthto_fields_list(nof_fields);\n"
" myleaf.body.node.nodes[idx_map[%lu]]->length = %d;\n"
" nof_fields = 0;\n",
sdef->elements[i].raw.fieldlength, (unsigned long)i,
(unsigned long)i, sdef->elements[i].typedescrname,
(unsigned long)i, sdef->elements[i].raw.lengthto_num,
(unsigned long)i, sdef->elements[i].raw.unit,
(unsigned long)i, (unsigned long)i, sdef->elements[i].raw.unit,
(unsigned long)i, sdef->elements[i].raw.lengthto_offset,
(unsigned long)i, sdef->elements[i].raw.lengthto_num,
(unsigned long)i, sdef->elements[i].raw.fieldlength);
(unsigned long)i, (unsigned long)i, sdef->elements[i].raw.fieldlength);
for (a = 0; a < sdef->elements[i].raw.lengthto_num; a++) {
src = mputprintf(src,
" if (idx_map[%lu] >= 0",
(unsigned long)sdef->elements[i].raw.lengthto[a]);
if (sdef->elements[sdef->elements[i].raw.lengthto[a]].isOptional) {
src = mputprintf(src,
" if (field_%s.ispresent()) {\n",
" && field_%s.ispresent()",
sdef->elements[sdef->elements[i].raw.lengthto[a]].name);
}
src = mputprintf(src,
" myleaf.body.node.nodes[idx_map[%lu]]->calcof.lengthto.fields[%lu].level = "
") {\n"
" myleaf.body.node.nodes[idx_map[%lu]]->calcof.lengthto.fields[nof_fields].level = "
"myleaf.body.node.nodes[idx_map[%lu]]->curr_pos.level;\n"
" myleaf.body.node.nodes[idx_map[%lu]]->calcof.lengthto.fields[%lu].pos = "
"myleaf.body.node.nodes[idx_map[%lu]]->curr_pos.pos;\n",
(unsigned long)i, (unsigned long)a,
" myleaf.body.node.nodes[idx_map[%lu]]->calcof.lengthto.fields[nof_fields++].pos = "
"myleaf.body.node.nodes[idx_map[%lu]]->curr_pos.pos;\n"
" } else {\n"
" myleaf.body.node.nodes[idx_map[%lu]]->"
"calcof.lengthto.fields[nof_fields].level = 0;\n"
" myleaf.body.node.nodes[idx_map[%lu]]->"
"calcof.lengthto.fields[nof_fields++].pos = 0;\n"
" }\n"
" if (idx_map_before[%lu] >= 0) {\n"
" myleaf.body.node.nodes[idx_map[%lu]]->calcof.lengthto.fields[nof_fields].level = "
"myleaf.body.node.nodes[idx_map_before[%lu]]->curr_pos.level;\n"
" myleaf.body.node.nodes[idx_map[%lu]]->calcof.lengthto.fields[nof_fields++].pos = "
"myleaf.body.node.nodes[idx_map_before[%lu]]->curr_pos.pos;\n"
" }\n"
" if (idx_map_after[%lu] >= 0) {\n"
" myleaf.body.node.nodes[idx_map[%lu]]->calcof.lengthto.fields[nof_fields].level = "
"myleaf.body.node.nodes[idx_map_after[%lu]]->curr_pos.level;\n"
" myleaf.body.node.nodes[idx_map[%lu]]->calcof.lengthto.fields[nof_fields++].pos = "
"myleaf.body.node.nodes[idx_map_after[%lu]]->curr_pos.pos;\n"
" }\n",
(unsigned long)i,
(unsigned long)sdef->elements[i].raw.lengthto[a],
(unsigned long)i,
(unsigned long)sdef->elements[i].raw.lengthto[a],
(unsigned long)i, (unsigned long)i,
(unsigned long)sdef->elements[i].raw.lengthto[a],
(unsigned long)i, (unsigned long)a,
(unsigned long)i,
(unsigned long)sdef->elements[i].raw.lengthto[a],
(unsigned long)i,
(unsigned long)sdef->elements[i].raw.lengthto[a],
(unsigned long)sdef->elements[i].raw.lengthto[a],
(unsigned long)i,
(unsigned long)sdef->elements[i].raw.lengthto[a],
(unsigned long)i,
(unsigned long)sdef->elements[i].raw.lengthto[a]);
if (sdef->elements[sdef->elements[i].raw.lengthto[a]].isOptional) {
src = mputprintf(src,
" } else {\n"
" myleaf.body.node.nodes[idx_map[%lu]]->"
"calcof.lengthto.fields[%lu].level = 0;\n"
" myleaf.body.node.nodes[idx_map[%lu]]->"
"calcof.lengthto.fields[%lu].pos = 0;\n"
" }\n",
(unsigned long)i, (unsigned long)a,
(unsigned long)i, (unsigned long)a);
}
}
/* Closing inner index check. */
src = mputstr(src,
" }\n");
/* Closing outer index check. */
src = mputstr(src,
" }\n");
......@@ -1289,7 +1319,7 @@ char *generate_raw_coding_negtest(char *src, const struct_def *sdef,
" break;\n"
" }\n"
" }\n"
" if (idx_map[%lu] < 0 || idx_map[%lu] < 0 ||\n"
" if (altered_[%lu] || altered_[%lu] ||\n"
" %lu != idx_map[%lu] - idx_map[%lu] || in_between_modified_pointerto_%s) {\n"
" e_c.set_msg(\"Field '%s' and/or '%s': \");\n"
" TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_NEGTEST_CONFL,\n"
......@@ -1338,10 +1368,10 @@ char *generate_raw_coding_negtest(char *src, const struct_def *sdef,
/* Encoding of normal fields with no negative testing. Needed for the
later phase. */
src = mputprintf(src,
" if (idx_map[%lu] >= 0) "
" if (!altered_[%lu] && idx_map[%lu] >= 0) "
"encoded_length += field_%s%s.RAW_encode(%s_descr_, "
"*myleaf.body.node.nodes[idx_map[%lu]]);\n",
(unsigned long)i, sdef->elements[i].name,
(unsigned long)i, (unsigned long)i, sdef->elements[i].name,
sdef->elements[i].isOptional ? "()" : "",
sdef->elements[i].typedescrname, (unsigned long)i);
}
......@@ -1361,7 +1391,7 @@ char *generate_raw_coding_negtest(char *src, const struct_def *sdef,
sdef->elements[i].name);
}
src = mputprintf(src,
" if (idx_map[%lu] < 0) {\n"
" if (altered_[%lu]) {\n"
" e_c.set_msg(\"Field '%s': \");\n"
" TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_NEGTEST_CONFL,\n"
" \"Conflicting negative testing attributes, LENGTHTO/LENGTHINDEX "
......@@ -1373,7 +1403,7 @@ char *generate_raw_coding_negtest(char *src, const struct_def *sdef,
sdef->elements[i].raw.lengthindex->nthfield);
for (a = 0; a < sdef->elements[i].raw.lengthto_num; a++) {
src = mputprintf(src,
" if (idx_map[%lu] < 0) {\n"
" if (altered_[%lu]) {\n"
" negtest_confl_lengthto = TRUE;\n"
" e_c.set_msg(\"Field '%s': \");\n"
" TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_NEGTEST_CONFL,\n"
......@@ -1454,7 +1484,7 @@ char *generate_raw_coding_negtest(char *src, const struct_def *sdef,
}
src = mputprintf(src,
" {\n"
" if (idx_map[%lu] < 0) {\n"
" if (altered_[%lu]) {\n"
" e_c.set_msg(\"Field '%s': \");\n"
" TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_NEGTEST_CONFL,\n"
" \"Conflicting negative testing attributes, LENGTHTO/LENGTHINDEX "
......@@ -1464,7 +1494,7 @@ char *generate_raw_coding_negtest(char *src, const struct_def *sdef,
(unsigned long)i, sdef->elements[i].name);
for (a = 0; a < sdef->elements[i].raw.lengthto_num; a++) {
src = mputprintf(src,
" if (idx_map[%lu] < 0) {\n"
" if (altered_[%lu]) {\n"
" negtest_confl_lengthto = TRUE;\n"
" e_c.set_msg(\"Field '%s': \");\n"
" TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_NEGTEST_CONFL,\n"
......@@ -1538,7 +1568,7 @@ char *generate_raw_coding_negtest(char *src, const struct_def *sdef,
sdef->raw.taglist.list + raw_options[i].tag_type - 1;
src = mputprintf(src,
" boolean negtest_confl_tag_%s = FALSE;\n"
" if (idx_map[%lu] < 0) {\n"
" if (altered_[%lu]) {\n"
" negtest_confl_tag_%s = TRUE;\n"
" e_c.set_msg(\"Field '%s': \");\n"
" TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_NEGTEST_CONFL,\n"
......@@ -1564,7 +1594,7 @@ char *generate_raw_coding_negtest(char *src, const struct_def *sdef,
/* The optional field itself. */
src = mputprintf(src,
" boolean negtest_confl_presence_%s = FALSE;\n"
" if (idx_map[%lu] < 0) {\n"
" if (altered_[%lu]) {\n"
" negtest_confl_presence_%s = TRUE;\n"
" e_c.set_msg(\"Field '%s': \");\n"
" TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_NEGTEST_CONFL,\n"
......@@ -1583,7 +1613,7 @@ char *generate_raw_coding_negtest(char *src, const struct_def *sdef,
if (field_idx == 0) {
rawAST_coding_fields *field = fields->fields + field_idx;
src = mputprintf(src,
" if (idx_map[%d] < 0) {\n"
" if (altered_[%d]) {\n"
" negtest_confl_presence_%s = TRUE;\n"
" e_c.set_msg(\"Field '%s': \");\n"
" TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_NEGTEST_CONFL,\n"
......@@ -1614,7 +1644,7 @@ char *generate_raw_coding_negtest(char *src, const struct_def *sdef,
int a;
/* The union field itself. */
src = mputprintf(src,
" if (idx_map[%lu] < 0) {\n"
" if (altered_[%lu]) {\n"
" e_c.set_msg(\"Field '%s': \");\n"
" TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_NEGTEST_CONFL,\n"
" \"Conflicting negative testing attributes, CROSSTAG attribute "
......@@ -1646,7 +1676,7 @@ char *generate_raw_coding_negtest(char *src, const struct_def *sdef,
if (field_idx == 0) {
rawAST_coding_fields *field = fields->fields + field_idx;
src = mputprintf(src,
" if (idx_map[%d] < 0) {\n"
" if (altered_[%d]) {\n"
" negtest_confl_crosstag = TRUE;\n"
" e_c.set_msg(\"Field '%s': \");\n"
" TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_NEGTEST_CONFL,\n"
......@@ -1818,7 +1848,7 @@ char *generate_raw_coding_negtest(char *src, const struct_def *sdef,
if (field_idx == 0) {
rawAST_coding_fields *field = fields->fields + field_idx;
src = mputprintf(src,
" if (idx_map[%d] < 0) {\n"
" if (altered_[%d]) {\n"
" negtest_confl_presence = TRUE;\n"
" e_c.set_msg(\"Field '%s': \");\n"
" TTCN_EncDec_ErrorContext::error(TTCN_EncDec::ET_NEGTEST_CONFL,\n"
......
......@@ -1281,9 +1281,9 @@ testcase raw_negtest_records() runs on MyComp
if (rawenc1(cmr11) == '80B100'O) { setverdict(pass) } else { setverdict(fail) }
if (rawenc1(cmr12) == '802A726F636B72696467652A'O) { setverdict(pass) } else { setverdict(fail) }
if (rawenc1(cmr13) == '80'O) { setverdict(pass) } else { setverdict(fail) }
if (rawenc9(cmr14) == '01070101756E69636F726E01'O) { setverdict(pass) } else { setverdict(fail) }
if (rawenc11(cmr15) == '010601017069636E696301'O) { setverdict(pass) } else { setverdict(fail) }
if (rawenc13(cmr16) == '010A01016D6F636B01747572746C65'O) { setverdict(pass) } else { setverdict(fail) }
if (rawenc9(cmr14) == '01090101756E69636F726E01'O) { setverdict(pass) } else { setverdict(fail) }
if (rawenc11(cmr15) == '010801017069636E696301'O) { setverdict(pass) } else { setverdict(fail) }
if (rawenc13(cmr16) == '010C01016D6F636B01747572746C65'O) { setverdict(pass) } else { setverdict(fail) }
if (rawenc15(cmr17) == '010264696E6E657262656C6C01'O) { setverdict(pass) } else { setverdict(fail) }
if (rawenc17(cmr18) == '010274696765726C696C7901'O) { setverdict(pass) } else { setverdict(fail) }
if (rawenc19(cmr19) == '01010001'O) { setverdict(pass) } else { setverdict(fail) }
......@@ -1315,9 +1315,9 @@ testcase raw_negtest_records() runs on MyComp
if (rawenc2(cms11) == '80B100'O) { setverdict(pass) } else { setverdict(fail) }
if (rawenc2(cms12) == '802A726F636B72696467652A'O) { setverdict(pass) } else { setverdict(fail) }
if (rawenc2(cms13) == '80'O) { setverdict(pass) } else { setverdict(fail) }
if (rawenc10(cms14) == '01070101756E69636F726E01'O) { setverdict(pass) } else { setverdict(fail) }
if (rawenc12(cms15) == '010601017069636E696301'O) { setverdict(pass) } else { setverdict(fail) }
if (rawenc14(cms16) == '010A01016D6F636B01747572746C65'O) { setverdict(pass) } else { setverdict(fail) }
if (rawenc10(cms14) == '01090101756E69636F726E01'O) { setverdict(pass) } else { setverdict(fail) }
if (rawenc12(cms15) == '010801017069636E696301'O) { setverdict(pass) } else { setverdict(fail) }
if (rawenc14(cms16) == '010C01016D6F636B01747572746C65'O) { setverdict(pass) } else { setverdict(fail) }
if (rawenc16(cms17) == '010264696E6E657262656C6C01'O) { setverdict(pass) } else { setverdict(fail) }
if (rawenc18(cms18) == '010274696765726C696C7901'O) { setverdict(pass) } else { setverdict(fail) }
if (rawenc20(cms19) == '01010001'O) { setverdict(pass) } else { setverdict(fail) }
......@@ -1349,9 +1349,9 @@ testcase raw_negtest_records() runs on MyComp
if (rawenc1(valueof(tmr11)) == '80B100'O) { setverdict(pass) } else { setverdict(fail) }
if (rawenc1(valueof(tmr12)) == '802A726F636B72696467652A'O) { setverdict(pass) } else { setverdict(fail) }
if (rawenc1(valueof(tmr13)) == '80'O) { setverdict(pass) } else { setverdict(fail) }
if (rawenc9(valueof(tmr14)) == '01070101756E69636F726E01'O) { setverdict(pass) } else { setverdict(fail) }
if (rawenc11(valueof(tmr15)) == '010601017069636E696301'O) { setverdict(pass) } else { setverdict(fail) }
if (rawenc13(valueof(tmr16)) == '010A01016D6F636B01747572746C65'O) { setverdict(pass) } else { setverdict(fail) }
if (rawenc9(valueof(tmr14)) == '01090101756E69636F726E01'O) { setverdict(pass) } else { setverdict(fail) }
if (rawenc11(valueof(tmr15)) == '010801017069636E696301'O) { setverdict(pass) } else { setverdict(fail) }
if (rawenc13(valueof(tmr16)) == '010C01016D6F636B01747572746C65'O) { setverdict(pass) } else { setverdict(fail) }
if (rawenc15(valueof(tmr17)) == '010264696E6E657262656C6C01'O) { setverdict(pass) } else { setverdict(fail) }
if (rawenc17(valueof(tmr18)) == '010274696765726C696C7901'O) { setverdict(pass) } else { setverdict(fail) }
if (rawenc19(valueof(tmr19)) == '01010001'O) { setverdict(pass) } else { setverdict(fail) }
......@@ -1383,9 +1383,9 @@ testcase raw_negtest_records() runs on MyComp
if (rawenc2(valueof(tms11)) == '80B100'O) { setverdict(pass) } else { setverdict(fail) }
if (rawenc2(valueof(tms12)) == '802A726F636B72696467652A'O) { setverdict(pass) } else { setverdict(fail) }
if (rawenc2(valueof(tms13)) == '80'O) { setverdict(pass) } else { setverdict(fail) }
if (rawenc10(valueof(tms14)) == '01070101756E69636F726E01'O) { setverdict(pass) } else { setverdict(fail) }
if (rawenc12(valueof(tms15)) == '010601017069636E696301'O) { setverdict(pass) } else { setverdict(fail) }
if (rawenc14(valueof(tms16)) == '010A01016D6F636B01747572746C65'O) { setverdict(pass) } else { setverdict(fail) }
if (rawenc10(valueof(tms14)) == '01090101756E69636F726E01'O) { setverdict(pass) } else { setverdict(fail) }
if (rawenc12(valueof(tms15)) == '010801017069636E696301'O) { setverdict(pass) } else { setverdict(fail) }
if (rawenc14(valueof(tms16)) == '010C01016D6F636B01747572746C65'O) { setverdict(pass) } else { setverdict(fail) }
if (rawenc16(valueof(tms17)) == '010264696E6E657262656C6C01'O) { setverdict(pass) } else { setverdict(fail) }
if (rawenc18(valueof(tms18)) == '010274696765726C696C7901'O) { setverdict(pass) } else { setverdict(fail) }
if (rawenc20(valueof(tms19)) == '01010001'O) { setverdict(pass) } else { setverdict(fail) }
......@@ -1760,7 +1760,7 @@ testcase negtest_compare_with_octetstring_RAW_special() runs on MyComp
//log(encode_RawSpecTest_Rec_LengthTo(c_lengthto3)); // 'EE03FFEE11FFEE22FFEE33FFEE44FFEE55FF'O
if (encode_RawSpecTest_Rec_LengthTo(c_lengthto1)=='0311FF33FF55'O) { setverdict(pass) } else { setverdict(fail) }
if (encode_RawSpecTest_Rec_LengthTo(c_lengthto2)=='12345678901122334455'O) { setverdict(pass) } else { setverdict(fail) }
if (encode_RawSpecTest_Rec_LengthTo(c_lengthto3)=='EE03FFEE11FFEE22FFEE33FFEE44FFEE55FF'O) { setverdict(pass) } else { setverdict(fail) }
if (encode_RawSpecTest_Rec_LengthTo(c_lengthto3)=='EE09FFEE11FFEE22FFEE33FFEE44FFEE55FF'O) { setverdict(pass) } else { setverdict(fail) }
////////////////////////
// LENGTHTO / LENGTHINDEX
......@@ -1787,6 +1787,139 @@ testcase negtest_compare_with_octetstring_RAW_special() runs on MyComp
///if (encode_RawSpecTest_Rec_PointerTo(c_pointerto4)==''O) { setverdict(pass) } else { setverdict(fail) }
}
// Testing LENGTHTO with erroneous values
type record Rec {
integer len,
octetstring data
}
with {
encode "RAW";
variant (len) "LENGTHTO(data)";
}
external function f_enc(in Rec x) return octetstring
with { extension "prototype(convert) encode(RAW) errorbehavior(ALL:WARNING)" }
const Rec val_good := { 0, '1234ABCD'O };
const Rec val_bad1 := { 0, '1234ABCD'O }
with {
erroneous (data) "value := 'ABCD'O";
}
const Rec val_bad2 := { 0, '1234ABCD'O }
with {
erroneous (data) "value := omit";
}
const Rec val_bad3 := { 0, '1234ABCD'O }
with {
erroneous (data) "before := '9876'O";
}
const Rec val_bad4 := { 0, '1234ABCD'O }
with {
erroneous (data) "after := 'FEDC'O";
}
const Rec val_bad5 := { 0, '1234ABCD'O }
with {
erroneous (data) "value (raw) := '1101010110110011'B";
}
const Rec val_bad6 := { 0, '1234ABCD'O }
with {
erroneous (data) "value := charstring:\"abc\"";
}
const Rec val_bad7 := { 0, '1234ABCD'O }
with {
erroneous (len) "value := 10";
}
type record Rec2 {
integer num,
charstring str
}
with {
encode "RAW";
}
const Rec val_bad8 := { 0, '1234ABCD'O }
with {
erroneous (data) "value := Rec2: { num := 3, str := \"ab\" }";
}
const Rec val_bad9 := { 0, '1234ABCD'O }
with {
erroneous (len) "value := Rec2: { num := 3, str := \"ab\" }";
}
testcase tc_negtest_lengthto() runs on MyComp {
var octetstring enc_good := f_enc(val_good);
var octetstring enc_good_exp := '041234ABCD'O;
if (enc_good != enc_good_exp) {
setverdict(fail, "Good failed. Expected: ", enc_good_exp, ", got: ", enc_good);
}
var octetstring enc_bad1 := f_enc(val_bad1);
var octetstring enc_bad1_exp := '02ABCD'O;
if (enc_bad1 != enc_bad1_exp) {
setverdict(fail, "Bad #1 failed. Expected: ", enc_bad1_exp, ", got: ", enc_bad1);
}
var octetstring enc_bad2 := f_enc(val_bad2);
var octetstring enc_bad2_exp := '00'O;
if (enc_bad2 != enc_bad2_exp) {
setverdict(fail, "Bad #2 failed. Expected: ", enc_bad2_exp, ", got: ", enc_bad2);
}
var octetstring enc_bad3 := f_enc(val_bad3);
var octetstring enc_bad3_exp := '0698761234ABCD'O;
if (enc_bad3 != enc_bad3_exp) {
setverdict(fail, "Bad #3 failed. Expected: ", enc_bad3_exp, ", got: ", enc_bad3);
}
var octetstring enc_bad4 := f_enc(val_bad4);
var octetstring enc_bad4_exp := '061234ABCDFEDC'O;
if (enc_bad4 != enc_bad4_exp) {
setverdict(fail, "Bad #4 failed. Expected: ", enc_bad4_exp, ", got: ", enc_bad4);
}
var octetstring enc_bad5 := f_enc(val_bad5);
var octetstring enc_bad5_exp := '02ABCD'O;
if (enc_bad5 != enc_bad5_exp) {
setverdict(fail, "Bad #5 failed. Expected: ", enc_bad5_exp, ", got: ", enc_bad5);
}
var octetstring enc_bad6 := f_enc(val_bad6);
var octetstring enc_bad6_exp := '03616263'O;
if (enc_bad6 != enc_bad6_exp) {
setverdict(fail, "Bad #6 failed. Expected: ", enc_bad6_exp, ", got: ", enc_bad6);
}
var octetstring enc_bad7 := f_enc(val_bad7);
var octetstring enc_bad7_exp := '0A1234ABCD'O;
if (enc_bad7 != enc_bad7_exp) {
setverdict(fail, "Bad #7 failed. Expected: ", enc_bad7_exp, ", got: ", enc_bad7);
}
var octetstring enc_bad8 := f_enc(val_bad8);
var octetstring enc_bad8_exp := '03036162'O;
if (enc_bad8 != enc_bad8_exp) {
setverdict(fail, "Bad #8 failed. Expected: ", enc_bad8_exp, ", got: ", enc_bad8);
}
var octetstring enc_bad9 := f_enc(val_bad9);
var octetstring enc_bad9_exp := '0361621234ABCD'O;
if (enc_bad9 != enc_bad9_exp) {
setverdict(fail, "Bad #9 failed. Expected: ", enc_bad9_exp, ", got: ", enc_bad9);
}
setverdict(pass);
}
control {
execute(negtest_compare_with_erroneous_types_BER());
execute(negtest_compare_with_octetstring_BER());
......@@ -1797,5 +1930,6 @@ control {
execute(raw_negtest_unions());
execute(negtest_compare_with_erroneous_types_RAW_special());
execute(negtest_compare_with_octetstring_RAW_special());
execute(tc_negtest_lengthto());
}
}
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