Commit e0cf3b34 authored by balaskoa's avatar balaskoa
Browse files

JsonTypes.ttcn is splitted into two parts


Signed-off-by: default avatarbalaskoa <Jeno.Balasko@ericsson.com>
parent e1d070f0
......@@ -46,11 +46,10 @@
#JsonTestcases.tc_asn_objid_and_any
#JsonTestcases.tc_asn_optional_null
#JsonTestcases.tc_record_empty
#JsonTestcases.tc_verdicttype
#JsonTestcases.tc_charstring_ascii_basic_escapes
#JsonTestcases.tc_binary_strings_with_white_spaces
JsonBasicAttributeTest.control
#JsonBasicAttributeTest.control
#JsonBasicAttributeTest.tc_attr_enum_text_attr #bad result
###########################################
......
......@@ -7,7 +7,7 @@
### cfgFile ###
#"src/cfgFile/define/macro_reference/TSTM_macro_test_main.cfg" #nok, it went 57 pass but now stops with StackOverflowError
#"src/cfgFile/define/structured/structured.cfg" #TODO: SError while setting parameter field 'tsp_1' to 'a': Referenced module parameter cannot be found. Module `a' does not exist, and no parameter with name `a' exists in any module.
#"src/cfgFile/define/structured/structured.cfg" #TODO: Error while setting parameter field 'tsp_1' to 'a': Referenced module parameter cannot be found. Module `a' does not exist, and no parameter with name `a' exists in any module.
"src/cfgFile/module_parameters/assignment/assignment.cfg" #enum modulepar, 19 pass
"src/cfgFile/module_parameters/concat/concat.cfg" #fixed: record concat, &= in cfg file
#"src/cfgFile/module_parameters/nested/nested.cfg" #TODO; it is simplified and reported in NestedRoI; RT2 bugfix it! Dot notation problem! Reported
......@@ -142,7 +142,7 @@ JsonBasicEncDecTest_os # 30 pass, 5 commented out --see in bugs
JsonBasicTest_ucharstring # 7pass, 1 commented out
##TODO:JsonComplexTest
JsonTestcases.control #59 pass, 12 commented out (2 fail , 10 error )
JsonTestcases.control #60 pass, 11 commented out (2 fail , 9 error )
#AttributeTestcases.control #14 pass (60.87 %), 0 inconc (0 %), 1 fail (4.348 %), 8 error (34.783 %)
#Bson
#Cbor
......
......@@ -22,7 +22,7 @@
#JsonBasicEncDecTest_os.tc_jsonBasic_encdec_os_AI3 #bad result
## JsonComplexTest folder ##
#JsonTestcases.control #59 pass, 12 commented out (2 fail , 10 error )
JsonTestcases.control #60 pass, 11 commented out (2 fail , 9 error )
#failing tests, commented out in the control part:
#JsonTestcases.tc_asn_seq
#JsonTestcases.tc_array_float
......@@ -33,7 +33,6 @@
#JsonTestcases.tc_asn_objid_and_any
#JsonTestcases.tc_asn_optional_null
#JsonTestcases.tc_record_empty
#JsonTestcases.tc_verdicttype
#JsonTestcases.tc_charstring_ascii_basic_escapes
#JsonTestcases.tc_binary_strings_with_white_spaces
......
......@@ -13,15 +13,16 @@
module AttributeTestcases {
import from JsonFunctions all;
import from JsonTypes all;
import from JsonTypes1 all;
import from JsonTypes0 all;
type component CT {}
//tests in case of no attributes:
//if omit fields do not appear in the encoded text
//if all not omitted field appear in the encoded text
//if all not omitted field value appear in the correct form
testcase tc_NoAttributeOnUpperLevel() runs on MTC {
testcase tc_NoAttributeOnUpperLevel() runs on CT {
var Profile0 p := {
name := "Bob",
phone_no := { 6, 1, 3377760 },
......@@ -37,7 +38,7 @@ testcase tc_NoAttributeOnUpperLevel() runs on MTC {
//tests in case of selecting attributes:
//if omit fields appear in the encoded
//if all not omitted field value appear in the correct form
testcase tc_name_as_omit_as_null() runs on MTC {
testcase tc_name_as_omit_as_null() runs on CT {
var Profile p := {
name := "Bob",
phone_no := { 6, 1, 3377760 },
......@@ -52,7 +53,7 @@ testcase tc_name_as_omit_as_null() runs on MTC {
f_bool2verdict( match(pd, p) );
}
testcase tc_name_as() runs on MTC {
testcase tc_name_as() runs on CT {
var Profile p := {
name := "Bob",
phone_no := { 6, 1, 3377760 },
......@@ -66,7 +67,7 @@ testcase tc_name_as() runs on MTC {
}
// testing attribute "name as ..." when the aliases are keywords of the JSON variant syntax
testcase tc_name_as_with_keywords() runs on MTC {
testcase tc_name_as_with_keywords() runs on CT {
var KeywordFields p := { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
var octetstring os := char2oct("{\"omit\":1,\"as\":2,\"null\":3,\"name\":4,\"value\":5,\"default\":6,\"extend\":7,\"metainfo\":8,\"for\":9,\"unbound\":10,\"JSON\":11}");
f_check_encoding(encoded := f_enc_kw_fld(p), expected := os);
......@@ -76,7 +77,7 @@ testcase tc_name_as_with_keywords() runs on MTC {
//tests in case of selecting attributes:
//if omit fields appear in the encoded
//if all not omitted field value appear in the correct form
testcase tc_attribute_compactprint1() runs on MTC {
testcase tc_attribute_compactprint1() runs on CT {
var Profile p := {
name := "Bob",
phone_no := { 6, 1, 3377760 },
......@@ -89,7 +90,7 @@ testcase tc_attribute_compactprint1() runs on MTC {
f_bool2verdict( match(f_dec_profile(f_enc_profile_compact(p)), p) );
}
testcase tc_attribute_compactprint2() runs on MTC {
testcase tc_attribute_compactprint2() runs on CT {
var Profile p := {
name := "Bob",
phone_no := { 6, 1, 3377760 },
......@@ -102,7 +103,7 @@ testcase tc_attribute_compactprint2() runs on MTC {
f_bool2verdict( match(f_dec_profile(f_enc_profile_compact(p)), p) );
}
testcase tc_attribute_compactprintp() runs on MTC {
testcase tc_attribute_compactprintp() runs on CT {
var Profile p := {
name := "Bob",
phone_no := { 6, 1, 3377760 },
......@@ -120,7 +121,7 @@ testcase tc_attribute_compactprintp() runs on MTC {
//if omit fields appear in the encoded
//if all not omitted field value appear in the correct form
//pretty printing
testcase tc_attribute_prettyprint1() runs on MTC {
testcase tc_attribute_prettyprint1() runs on CT {
var Profile p := {
name := "Bob",
phone_no := { 6, 1, 3377760 },
......@@ -134,7 +135,7 @@ testcase tc_attribute_prettyprint1() runs on MTC {
}
//pretty printing
testcase tc_attribute_prettyprint2() runs on MTC {
testcase tc_attribute_prettyprint2() runs on CT {
var Profile p := {
name := "Bob",
phone_no := { 6, 1, 3377760 },
......@@ -149,7 +150,7 @@ testcase tc_attribute_prettyprint2() runs on MTC {
testcase tc_attribute_union() runs on MTC {
testcase tc_attribute_union() runs on CT {
var CBA c:= {
f_val:= 1.75
}
......@@ -176,7 +177,7 @@ testcase tc_attribute_union() runs on MTC {
// Encoding unions as JSON values (without the braces and the field name)
// The decoder will attempt to decode each field and the first to successfully decode the value
// will be the selected one (thus the order of the fields is important)
testcase tc_attribute_as_value() runs on MTC {
testcase tc_attribute_as_value() runs on CT {
var Stuff stuff := { { ival := 18 }, { osval := '1D66FE'O }, { csval := "almafa" }, { bval := true }, { fval := 1.8e-20}, { ucsval := "almácska" }, { bsval := '1101101'B }, { prodval := { name := "Shoe", price := 79.99, code := 'A4C'H } }, { roival := { 1, 3, 3, 7 } }, { prod2val := { "Car", 14000.0, omit } }, { sizeval := Large }, { unival := { hsval := 'EE0'H } }, { unival := { rocsval := { "one", "two", "ten" } } } };
var octetstring os := unichar2oct("[18,\"1D66FE\",\"almafa\",true,1.800000e-20,\"almácska\",\"1101101\",{\"name\":\"Shoe\",\"price\":79.990000,\"code\":\"A4C\"},[1,3,3,7],{\"name\":\"Car\",\"price\":14000.000000},\"Large\",\"EE0\",[\"one\",\"two\",\"ten\"]]", "UTF-8");
......@@ -186,7 +187,7 @@ testcase tc_attribute_as_value() runs on MTC {
}
// Testing default values for record fields (decoding only)
testcase tc_attribute_default() runs on MTC {
testcase tc_attribute_default() 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) );
......@@ -213,7 +214,7 @@ testcase tc_attribute_default() runs on MTC {
// field instead of omitting the union.
// The other union ('uniTtcn') cannot decode the JSON value 'null', thus decoding 'null' omits
// the union.
testcase tc_attribute_optional_as_value() runs on MTC {
testcase tc_attribute_optional_as_value() runs on CT {
var OptionalUnions val1 := { dummy := "nothing", uniTtcn := omit, uniAsn := omit };
var OptionalUnions val2 := { dummy := "nothing", uniTtcn := omit, uniAsn := { nval := NULL } };
var octetstring os := char2oct("{\"dummy\":\"nothing\",\"uniTtcn\":null,\"uniAsn\":null}");
......@@ -225,7 +226,7 @@ testcase tc_attribute_optional_as_value() runs on MTC {
// Encoding records and sets with unbound fields with meta info (attribute 'metainfo for unbound')
// The unbound fields will have the 'null' value and an extra (meta info) field will be inserted
// into the JSON document (after the current field) to specify that the field is unbound.
testcase tc_attribute_metainfo_for_unbound() runs on MTC {
testcase tc_attribute_metainfo_for_unbound() runs on CT {
// regular encoding and decoding tests
var MetainfoRecord r := { num := 6 };
var octetstring os := char2oct("{\"num\":6,\"str\":null,\"metainfo str\":\"unbound\"}");
......@@ -247,7 +248,7 @@ testcase tc_attribute_metainfo_for_unbound() runs on MTC {
}
// Negative tests for decoding with the unbound meta info attribute
testcase tc_attribute_metainfo_for_unbound_negtest() runs on MTC {
testcase tc_attribute_metainfo_for_unbound_negtest() runs on CT {
var octetstring os := char2oct("{ \"metainfo num\" : \"unbound\", \"num\" : 6, \"str\" : \"qwe\" }");
var MetainfoRecord dummyRec;
@try {
......@@ -320,7 +321,7 @@ testcase tc_attribute_metainfo_for_unbound_negtest() runs on MTC {
// Decoding test for the 'metainfo for unbound' attribute, where all fields of an embedded record are
// set to unbound by meta info. The decoded embedded record should be unbound.
testcase tc_attribute_metainfo_for_unbound_empty_rec() runs on MTC {
testcase tc_attribute_metainfo_for_unbound_empty_rec() runs on CT {
var charstring dec_str := "{\"mynum\":99,\"mystr\":\"aa\", \"myRec\": {\"num\":null,\"metainfo num\":\"unbound\",\"str\":null,\"metainfo str\":\"unbound\" } }";
var MetainfoOuterRecord dec_val := f_dec_meta_outer_rec(char2oct(dec_str));
if (isbound(dec_val.myRec)) {
......@@ -335,7 +336,7 @@ testcase tc_attribute_metainfo_for_unbound_empty_rec() runs on MTC {
// Encoding array types with unbound elements with meta info (attribute 'metainfo for unbound')
// A JSON object with one key-value pair (containing the meta info) specifies that an element is unbound.
testcase tc_attribute_metainfo_for_unbound_arrays() runs on MTC {
testcase tc_attribute_metainfo_for_unbound_arrays() runs on CT {
// test 1: pre-generated array type (record of integer)
var MetainfoRecOf recof := { 1, 2, -, 4 };
var octetstring os := char2oct("[1,2,{\"metainfo []\":\"unbound\"},4]");
......@@ -357,7 +358,7 @@ testcase tc_attribute_metainfo_for_unbound_arrays() runs on MTC {
// Encoding a record with one field without field names (attribute 'as value')
// The record value's encoding in this case is equal to the field's encoding
testcase tc_attribute_as_value_rec() runs on MTC {
testcase tc_attribute_as_value_rec() runs on CT {
var RecAsValue val := { field := 10 };
var bitstring enc_exp := oct2bit(char2oct("10"));
var bitstring enc := encvalue(val);
......@@ -385,7 +386,7 @@ testcase tc_attribute_as_value_rec() runs on MTC {
// Encoding a record with one field without any variant attributes
// (The code generated in this case is different, because of the possibility of
// adding the 'as value' attribute for a subtype)
testcase tc_attribute_not_as_value_rec() runs on MTC {
testcase tc_attribute_not_as_value_rec() runs on CT {
var RecNotAsValue val := { field := { 1.0, 2.0 } };
var bitstring enc_exp := oct2bit(char2oct("{\"field\":[1.000000,2.000000]}"));
var bitstring enc := encvalue(val);
......@@ -450,7 +451,7 @@ testcase tc_attribute_not_as_value_rec() runs on MTC {
// }
//}
testcase tc_attribute_as_number() runs on MTC {
testcase tc_attribute_as_number() runs on CT {
var RecWithAsNumber val := {
lengths := { Short, Medium, Long },
days := { Monday, Saturday, Thursday }
......@@ -478,7 +479,7 @@ testcase tc_attribute_as_number() runs on MTC {
}
}
testcase tc_attribute_as_number_negtest() runs on MTC {
testcase tc_attribute_as_number_negtest() runs on CT {
var RecWithAsNumber.lengths[-] val;
var bitstring stream := oct2bit(char2oct("\"Short\"")); // name form instead of number form
var integer res := decvalue(stream, val);
......@@ -509,7 +510,7 @@ testcase tc_attribute_as_number_negtest() runs on MTC {
}
// Testing the attribute 'default' on structures
testcase tc_attribute_default_struct() runs on MTC {
testcase tc_attribute_default_struct() runs on CT {
var DefaultEmptyStructs val;
var DefaultEmptyStructs exp_val := { {}, {}, {}, {} };
var universal charstring data := "{}";
......@@ -526,7 +527,7 @@ testcase tc_attribute_default_struct() runs on MTC {
}
// Testing the attribute 'chosen'
testcase tc_attribute_chosen() runs on MTC {
testcase tc_attribute_chosen() runs on CT {
// one test for each chosen field
var PduWithIdList val := {
{ protocolId := 11, field1 := { type1 := { num := 1, str := "abc" } }, field2 := { type2 := { num := 2, str := "xyz" } } },
......@@ -572,7 +573,7 @@ testcase tc_attribute_chosen() runs on MTC {
// Testing JSON decoding when field selections of optional fields conflict with
// the settings in attribute 'chosen'
testcase tc_attribute_chosen_negtest() runs on MTC {
testcase tc_attribute_chosen_negtest() runs on CT {
// Test #1: protocolId indicates 'omit' (for field1), but the field is not omitted
@try {
var octetstring buff := char2oct("{\"protocolId\":3,\"field1\":{\"num\":1,\"str\":\"abc\"},\"field2\":{\"num\":2,\"str\":\"xyz\"}}");
......@@ -633,7 +634,7 @@ testcase tc_attribute_chosen_negtest() runs on MTC {
// Testing JSON decoding with attributes 'chosen' and 'default'.
// (The conditions in the attribute 'chosen' depend on fields that have default values.)
testcase tc_attribute_chosen_default() runs on MTC {
testcase tc_attribute_chosen_default() runs on CT {
// Test #1: both fields use their default values
var octetstring buff := char2oct("{\"field\":{\"num\":1,\"str\":\"abc\"}}");
var PduWithId2 dec_exp := { protocolId1 := 1, protocolId2 := 0, field := { type1 := { num := 1, str := "abc" } } };
......@@ -680,7 +681,7 @@ testcase tc_attribute_chosen_default() runs on MTC {
}
// Testing the attribute 'as map'
testcase tc_attribute_as_map() runs on MTC {
testcase tc_attribute_as_map() runs on CT {
var Map x := { { "one", 1 }, { "two", 2 }, { "three", 3 }, { "zero", omit } };
var octetstring enc_exp := char2oct("{\"one\":1,\"two\":2,\"three\":3,\"zero\":null}");
var octetstring enc := f_enc_map(x);
......@@ -695,7 +696,7 @@ testcase tc_attribute_as_map() runs on MTC {
}
// Testing the attribute 'as map' in a union with the attribute 'as value'
testcase tc_attribute_as_map_in_union() runs on MTC {
testcase tc_attribute_as_map_in_union() runs on CT {
var JsonValue x := {
JsonObject := {
{
......@@ -721,7 +722,7 @@ testcase tc_attribute_as_map_in_union() runs on MTC {
}
// Testing the attribute 'text ... as ...'
testcase tc_attribute_text_as() runs on MTC {
testcase tc_attribute_text_as() runs on CT {
var EnumNumberList x := { One, Two, Three };
var octetstring enc_exp := char2oct("[\"1\",\"2\",\"3\"]");
var octetstring enc := f_enc_enum_list(x);
......
......@@ -13,7 +13,8 @@
module JsonFunctions
{
import from JsonTypes all;
import from JsonTypes0 all;
import from JsonTypes1 all;
import from JsonData language "ASN.1" all;
import from OtherTypes all;
......
......@@ -13,10 +13,13 @@
module JsonTestcases {
import from JsonFunctions all;
import from JsonTypes all;
import from JsonTypes0 all;
import from JsonTypes1 all;
import from JsonData language "ASN.1" all;
import from OtherTypes all;
type component MTC {}
modulepar R tsp_r := {
i:= 1,
cs:="two",
......@@ -880,7 +883,7 @@ control {
execute(tc_hexstring_nonempty());
execute(tc_bitstring_empty());
execute(tc_bitstring_nonempty());
// execute(tc_verdicttype());
execute(tc_verdicttype());
execute(tc_float());
execute(tc_record());
execute(tc_record_const());
......
/******************************************************************************
* Copyright (c) 2000-2020 Ericsson Telecom AB
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
*
* Contributors:
* Balasko, Jeno
* Baranyi, Botond
*
******************************************************************************/
module JsonTypes0 {
import from JsonTypes1 all;
type record OptionalUnions {
charstring dummy,
Thing uniTtcn optional,
AsnThing uniAsn optional
} with {
variant(uniTtcn) "omit as null";
variant(uniAsn) " omit as null ";
}
type record MetainfoRecord {
integer num,
charstring str
}
with {
variant(str) "JSON: metainfo for unbound";
}
type set MetainfoSet {
integer num,
charstring str,
octetstring octets optional
}
with {
variant " JSON : metainfo for unbound ";
variant (num) " JSON : name as int ";
}
type record MetainfoInnerRecord {
integer num,
charstring str
}
with {
variant "JSON: metainfo for unbound";
}
type record MetainfoOuterRecord {
integer mynum,
charstring mystr,
MetainfoInnerRecord myRec
}
type record BinaryStrings {
bitstring bit,
hexstring hex,
octetstring oct
}
type record of integer MetainfoRecOf
with { variant "JSON: metainfo for unbound"; }
type set of MetainfoRecord MetainfoSetOf
with { variant "JSON: metainfo for unbound"; }
type float MetainfoArray[3]
with { variant "metainfo for unbound"; }
type record RecAsValue {
integer field
}
with {
variant "JSON: as value";
}
type record RecNotAsValue {
RoF field
}
type union UniNotAsValue {
integer i,
octetstring o
}
type set SetWithAsValueFields {
UniNotAsValue uni,
RecNotAsValue rec,
record of anytype list
}
with {
variant (uni) "JSON: as value";
variant (rec) "JSON: as value";
variant (list[-]) "asValue";
}
type record RecWithAsNumber {
record of enumerated { Short(0), Medium(50), Long(100) } lengths,
record of Days days
}
with {
variant (lengths[-]) "JSON: as number";
variant (days[-]) "as number";
}
type union Uni522660 {
integer f12,
integer f1
}
type record DefaultEmptyStructs {
record { } r,
set { } s,
record of integer ro,
set of charstring so
}
with {
variant (r) "JSON: default({})";
variant (s) "default({})";
variant (ro) "default({})";
variant (so) "JSON: default({})";
}
type record PduWithId {
integer protocolId,
Choices field1 optional,
Choices field2 optional
}
with {
variant (field1) "chosen (type1, { protocolId = 1, protocolId = 11 }; type2, protocolId = 2; omit, protocolId = 3; type3, otherwise)";
variant (field2) "chosen (type1, protocolId = 2; type2, { protocolId = 10, protocolId = 11 }; type3, protocolId = 3)"; // no otherwise
}
type union Choices {
StructType1 type1,
StructType2 type2,
StructType3 type3
}
type record StructType1 {
integer num,
charstring str
}
type record StructType2 {
integer num,
universal charstring str
}
type record StructType3 {
float num,
charstring str
}
type record of PduWithId PduWithIdList;
type record PduWithId2 {
integer protocolId1,
integer protocolId2,
Choices field optional
}
with {
variant (field) "chosen (type1, { protocolId1 = 1, protocolId2 = 1 }; type2, protocolId1 = 0; type3, protocolId2 = 0; omit, otherwise)";
variant (protocolId1) "default (1)";
variant (protocolId2) "default (0)";
}
type record MapItem {
universal charstring key,
integer value_ optional
}
type set of MapItem Map
with { variant "as map" }
type union JsonValue {
integer JsonInteger,
float JsonNumber,
boolean JsonBool,
universal charstring JsonString,
record of JsonValue JsonArray,
set of record {
universal charstring key,
JsonValue val
} JsonObject
}
with {
variant "JSON: as value"
variant (JsonObject) "as map";
}
type enumerated EnumNumber { One, Two, Three }
with {
variant "text 'One' as '1'";
variant "text 'Two' as '2'";
variant "text 'Three' as '3'";
}
type record of EnumNumber EnumNumberList;
} with {
encode "JSON";
extension "anytype integer, charstring, R, RoI, Thing";
}
......@@ -10,14 +10,12 @@
* Baranyi, Botond
*
******************************************************************************/
module JsonTypes {
module JsonTypes1 {
import from JsonData all;
const integer c_imported_i :=11;
type component MTC {}
type enumerated Days { Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday };
type record R {
......@@ -208,194 +206,7 @@ type union AsnThing {
type record of AsnThing AsnStuff;
type record OptionalUnions {
charstring dummy,
Thing uniTtcn optional,
AsnThing uniAsn optional
} with {
variant(uniTtcn) "omit as null";
variant(uniAsn) " omit as null ";
}
type record MetainfoRecord {
integer num,
charstring str
}
with {
variant(str) "JSON: metainfo for unbound";
}
type set MetainfoSet {
integer num,
charstring str,
octetstring octets optional
}
with {
variant " JSON : metainfo for unbound ";