Commit 086db506 authored by Adam Knapp's avatar Adam Knapp Committed by Arpad Lovassy

Regression test sync

Signed-off-by: Adam Knapp's avatarAdam Knapp <adam.knapp@ericsson.com>
parent ff6b0ca8
......@@ -185,8 +185,8 @@ testcase tc_attribute_as_value() runs on CT {
setverdict(pass);
}
// Testing default values for record fields (decoding only)
testcase tc_attribute_default() runs on CT {
// Testing legacy default values for record fields (decoding only)
testcase tc_attribute_default_legacy() runs on CT {
var octetstring os := char2oct("{}");
var RecDef d := { i := -19, f := 1000000.000000, b := false, bs := '101'B, hs := 'DEAD'H, os := '1DE7'O, cs := "empty", ucs := "üres", size := Tiny, vt := fail };
f_bool2verdict( match(f_dec_def(os), d) );
......@@ -196,6 +196,43 @@ testcase tc_attribute_default() runs on CT {
f_bool2verdict( match(f_dec_def(os), d) );
}
// Testing standard-compliant default values for record fields of basic types (decoding only)
testcase tc_attribute_default_basic() runs on CT {
var octetstring os := char2oct("{}");
var RecDef2 d := { i := -19, f := 1000000.000000, b := false, bs := '101'B, hs := 'DEAD'H, os := '1DE7'O, cs := "empty", ucs := "üres", size := Tiny, vt := fail };
f_bool2verdict( match(f_dec_def2(os), d) );
os := char2oct("{ \"b\" : null }");
d.b := omit;
f_bool2verdict( match(f_dec_def2(os), d) );
}
// Tests for standard-compliant default values taken from the TTCN-3 standard change request CR 7968 v5 (decoding only)
testcase tc_attribute_default_standard() runs on CT {
var octetstring os := char2oct("{ \"name\" : \"Shoe\", \"price\" : 29.50, \"text\" : \"available\" }");
var Product2 p := { name := "Shoe", price := 29.500000, id := 'FFFF'O, origin := "Hungary", text := "available" };
f_bool2verdict( match(f_dec_prod2(os), p) );
os := char2oct("{ \"name\" : \"Shirt\", \"price\" : 12.99, \"id\" : null }");
p := { name := "Shirt", price := 12.990000, id := omit, origin := "Hungary", text := char(1, 2, 3, 4) & char(5, 6, 7, 8) & "?" };
f_bool2verdict( match(f_dec_prod2(os), p) );
os := char2oct("{ \"name\" : \"test shopper\" }");
var Shopping_cart sc := { name := "test shopper", product := { name := "Shirt", price := 12.990000, id := omit, origin := "Hungary", text := "available" } };
f_bool2verdict( match(f_dec_cart(os), sc) );
os := char2oct("{ \"name\" : \"test shopper\" }");
var Shopping_cart_2 sc2 := { name := "test shopper", product := { name := "Size \"M\" Shirt", price := 12.990000, id := omit, origin := "Hungary", text := "available" } };
f_bool2verdict( match(f_dec_cart2(os), sc2) );
}
// Testing standard-compliant default values for record fields of structured types (decoding only)
testcase tc_attribute_default_structured() runs on CT {
var octetstring os := char2oct("{ }");
var RecDef3 d := { er := { }, u := { i := -6 }, roi := { 1, 2, 3 } };
f_bool2verdict( match(f_dec_def3(os), d) );
}
// Encoding a few values of ASN.1 types with the coding instruction "as value"
// Results are the same as with the TTCN-3 types
testcase tc_attribute_as_value_asn() runs on CT {
......@@ -746,7 +783,10 @@ control {
execute(tc_attribute_prettyprint2());
//execute(tc_attribute_union()); // error TODO: fix the error
//execute(tc_attribute_as_value()); // error TODO: fix the error
execute(tc_attribute_default());
execute(tc_attribute_default_legacy());
execute(tc_attribute_default_basic());
execute(tc_attribute_default_standard());
execute(tc_attribute_default_structured());
execute(tc_attribute_as_value_asn());
execute(tc_attribute_optional_as_value());
execute(tc_attribute_metainfo_for_unbound());
......
......@@ -322,6 +322,21 @@ external function f_dec_stuff(in octetstring x) return Stuff
external function f_dec_def(in octetstring x) return RecDef
with { extension "prototype(convert) decode(JSON)" }
external function f_dec_def2(in octetstring x) return RecDef2
with { extension "prototype(convert) decode(JSON)" }
external function f_dec_prod2(in octetstring x) return Product2
with { extension "prototype(convert) decode(JSON)" }
external function f_dec_cart(in octetstring x) return Shopping_cart
with { extension "prototype(convert) decode(JSON)" }
external function f_dec_cart2(in octetstring x) return Shopping_cart_2
with { extension "prototype(convert) decode(JSON)" }
external function f_dec_def3(in octetstring x) return RecDef3
with { extension "prototype(convert) decode(JSON)" }
external function f_dec_hpt(in octetstring x) return HasPardType
with { extension "prototype(convert) decode(JSON)" }
......
......@@ -190,6 +190,81 @@ type record RecDef {
variant(b) "JSON:default(false)";
}
type record RecDef2 {
integer i,
float f,
boolean b optional,
bitstring bs,
hexstring hs,
octetstring os,
charstring cs,
universal charstring ucs,
enumerated { Tiny, Small, Medium, Large, Huge } size,
verdicttype vt
} with {
variant(cs) "default(\"empty\")";
variant(i) "default(-19)";
variant(f) "default(1.0e6)";
variant(size) "default(Tiny)";
variant(os) "default('1DE7'O)";
variant(ucs) "default(""üres"")";
variant(bs) "default ('101'B)";
variant(hs) "default('DEAD'H)";
variant(vt) "default(fail)";
variant(b) "default(false)";
}
type record Product2 {
charstring name,
float price,
octetstring id optional,
charstring origin,
universal charstring text
}
with {
variant(id) "default ('FFFF'O)"
variant(origin) "default(""Hungary"")"
variant(text) "default (char(1,2,3,4\) & char(5,6,7,8\) & ""?"")"
}
type record Shopping_cart {
charstring name,
Product2 product
} with {
variant(product) "default ({""Shirt"", 12.99, omit, ""Hungary"", ""available"" })"
}
const Product2 c_defaultProduct := {
name := "Size ""M"" Shirt",
price := 12.99,
id := omit,
origin := "Hungary",
text := "available"
}
type record Shopping_cart_2 {
charstring name,
Product2 product
} with {
variant(product) "default (c_defaultProduct)"
}
type union Uni {
integer i,
charstring cs
}
type record RecDef3 {
EmptyRec er,
Uni u,
RoI roi
}
with {
variant (er) "default ( { } )";
variant (u) "default ({ i := -6 })";
variant (roi) "default ({1,2,3})";
}
type record HasPardType {
ProtocolElem_Field1 pard,
boolean buul,
......
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