Skip to content
Snippets Groups Projects
Commit c763bce6 authored by balaskoa's avatar balaskoa
Browse files

Synchronized with java side - JsonTypes.ttcn is split into 2 pieces


Signed-off-by: default avatarbalaskoa <Jeno.Balasko@ericsson.com>
Change-Id: I42fe0648908bd5bfc14b11ca14886c64a4184408
parent db654cd1
No related branches found
No related tags found
No related merge requests found
......@@ -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 },
......@@ -50,7 +51,7 @@ testcase tc_name_as_omit_as_null() runs on MTC {
f_bool2verdict( match(f_dec_profile(f_enc_profile(p)), 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 },
......@@ -64,7 +65,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);
......@@ -74,7 +75,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 },
......@@ -87,7 +88,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 },
......@@ -100,7 +101,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 },
......@@ -118,7 +119,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 },
......@@ -132,7 +133,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 },
......@@ -147,7 +148,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
}
......@@ -174,17 +175,18 @@ 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");
f_check_encoding(encoded:= f_enc_stuff(stuff) , expected := os);
f_bool2verdict( match(f_dec_stuff(f_enc_stuff(stuff)), stuff) );
//log(match(f_dec_stuff(f_enc_stuff(stuff)), stuff));
setverdict(pass);
}
// 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) );
......@@ -196,7 +198,7 @@ testcase tc_attribute_default() runs on MTC {
// 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 MTC {
testcase tc_attribute_as_value_asn() runs on CT {
var AsnStuff stuff := { { nval := NULL }, { ival := -10 }, { anyval := 'DCBA'O }, { vsval := "something" }, { pardval := { id := 0, priority := low, val := { iNTEGER := -10 } } } };
var octetstring os := char2oct("[null,-10,\"DCBA\",\"something\",{\"id\":0,\"priority\":\"low\",\"val\":{\"iNTEGER\":-10}}]");
f_check_encoding(encoded := f_enc_asn_stuff(stuff), expected := os);
......@@ -210,7 +212,7 @@ testcase tc_attribute_as_value_asn() 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}");
......@@ -222,7 +224,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\"}");
......@@ -244,7 +246,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 {
......@@ -317,7 +319,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)) {
......@@ -332,7 +334,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]");
......@@ -354,7 +356,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);
......@@ -382,7 +384,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);
......@@ -411,7 +413,7 @@ testcase tc_attribute_not_as_value_rec() runs on MTC {
// The base types of the fields do not have the 'as value' attribute set, only when they are used as
// fields of this set (one of the fields is an anytype, which cannot have this attribute otherwise).
// The set itself is encoded with field names, but its fields are encoded as values.
testcase tc_attribute_as_value_fields() runs on MTC {
testcase tc_attribute_as_value_fields() runs on CT {
var SetWithAsValueFields val := {
uni := { i := -3 },
rec := { field := { 1.0, 2.0 } },
......@@ -446,7 +448,7 @@ testcase tc_attribute_as_value_fields() 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 }
......@@ -474,7 +476,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);
......@@ -505,7 +507,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 := "{}";
......@@ -522,7 +524,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" } } },
......@@ -568,7 +570,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\"}}");
......@@ -629,7 +631,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" } } };
......@@ -676,7 +678,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);
......@@ -691,7 +693,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 := {
{
......@@ -717,7 +719,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;
......@@ -454,7 +455,7 @@ external function f_dec_pduwithid2(in octetstring x) return PduWithId2
//============== Internal Functions ====================
function f_check_encoding(in octetstring encoded, in octetstring expected) {
log("encoded: ",encoded," expected: ",expected)
//log("encoded: ",encoded," expected: ",expected)
if(encoded == expected) {
setverdict(pass);
} else {
......@@ -463,7 +464,7 @@ function f_check_encoding(in octetstring encoded, in octetstring expected) {
} with { extension "transparent"}
function f_check_encoding_bit(in bitstring encoded, in bitstring expected) {
log("encoded: ",encoded," expected: ",expected)
//log("encoded: ",encoded," expected: ",expected)
if(encoded == expected) {
setverdict(pass);
} else {
......
......@@ -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",
......@@ -26,9 +29,6 @@ modulepar R tsp_r := {
modulepar charstring tsp_cs_long := "123456789123456789123456789 abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz ;""'\\/\n\r\t\f\b.,<>?|:][{}=-+!@#$%^&*()";
const octetstring c_BOM_UTF8 :='EFBBBF'O;
const integer c_i :=18
......@@ -168,6 +168,7 @@ testcase tc_charstring_ascii_basic_escapes() runs on MTC{
testcase tc_charstring_ascii_extended1() runs on MTC{
var charstring cs := "Vire au Vert l"&char(0,0,0,224)&"!";
var octetstring os:= f_enc_cs( cs )
log(os);
f_check_encoding(encoded:= os, expected := char2oct(qm & cs & qm));
@try{
f_bool2verdict(cs==f_dec_cs(os));
......@@ -176,7 +177,6 @@ testcase tc_charstring_ascii_extended1() runs on MTC{
@catch(err_msg) {
setverdict(pass,"expected error, ok")
}
}
testcase tc_ucharstring_ascii_extended1_xer() runs on MTC{
......@@ -357,7 +357,6 @@ testcase tc_float() runs on MTC{
}
//============ enum ======================
testcase tc_enum() runs on MTC{
......@@ -931,7 +930,6 @@ control {
execute(tc_asn_choice());
execute(tc_asn_strings());
execute(tc_asn_complex());
execute(tc_asn_open_type_and_null());
execute(tc_asn_objid_and_any());
execute(tc_asn_optional_null());
......
......@@ -10,203 +10,9 @@
* Baranyi, Botond
*
******************************************************************************/
module JsonTypes {
module JsonTypes0 {
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 {
integer i,
charstring cs,
boolean b,
Days d
}
type record R2 {
R r,
float f
}
type record EmptyRec { }
type union A {
R r,
integer i,
boolean b,
float f
}
type record of universal charstring RoUCS;
type record of charstring RoCS;
type record of octetstring RoOS;
type record of integer RoI;
type record of verdicttype RoV;
type record of float RoF;
type integer IntArr[3];
type float FloatArr[3];
type universal charstring StrArr[4];
type record Date {
charstring month,
integer day_idx,
Days day_name
}
type record of Date Dates;
type record PhoneNumber {
integer country_prefix,
integer network_prefix,
integer local_number
} with {
variant(country_prefix) "JSON: name as CountryPrefix";
variant(network_prefix) "JSON: name as NetworkPrefix";
variant(local_number) "JSON : name as LocalNumber"
}
type record Profile0 {
charstring name,
PhoneNumber phone_no,
charstring email_addr optional,
Dates meetings optional
}
type record Profile {
charstring name,
PhoneNumber phone_no,
charstring email_addr optional,
Dates meetings optional
} with {
//variant(email_addr) "JSON : omit as null";
variant(meetings) "JSON:omit as null";
variant(phone_no) "JSON: name as phone";
variant(email_addr) "JSON: name as email";
}
type union CBA {
integer i_val,
Date date_val,
float f_val,
charstring cs_val
} with {
variant(date_val) "JSON:name as date";
variant(i_val) "JSON:name as int";
variant(f_val) "JSON:name as float";
variant(cs_val) "JSON:name as string";
}
type set Product {
charstring name,
float price optional,
hexstring code
} with {
variant(price) "JSON:omit as null"
}
type record KeywordFields {
integer a1,
integer a2,
integer a3,
integer a4,
integer a5,
integer a6,
integer a7,
integer a8,
integer a9,
integer a10,
integer a11
}
with {
variant(a1) "JSON: name as omit";
variant(a2) "JSON: name as as";
variant(a3) "JSON: name as null";
variant(a4) "JSON: name as name";
variant(a5) "JSON: name as value";
variant(a6) "JSON: name as default";
variant(a7) "JSON: name as extend";
variant(a8) "JSON: name as metainfo";
variant(a9) "JSON: name as for";
variant(a10) "JSON: name as unbound";
variant(a11) "JSON: name as JSON";
}
type union Thing {
integer ival,
float fval,
boolean bval,
enumerated { Tiny, Small, Average, Large, Huge } sizeval,
bitstring bsval,
octetstring osval,
union {
hexstring hsval,
record of charstring rocsval
} unival,
charstring csval,
universal charstring ucsval,
Product prodval,
record of integer roival,
record {
charstring name,
float price,
hexstring productID optional
} prod2val
} with {
variant "JSON:as value";
variant (prod2val.productID) "name as 'code'";
variant(unival) "JSON:as value";
}
type record of Thing Stuff;
type record RecDef {
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) "JSON : default(empty)";
variant(i) "JSON:default(-19)";
variant(f) "JSON:default(1.0e6)";
variant(size) "JSON:default(Tiny)";
variant(os) "JSON : default(1DE7)";
variant(ucs) "JSON:default(üres)";
variant(bs) "JSON:default (101)";
variant(hs) "JSON:default(DEAD)";
variant(vt) "JSON:default(fail)";
variant(b) "JSON:default(false)";
}
type record HasPardType {
ProtocolElem_Field1 pard,
boolean buul,
Price price
}
type union AsnThing {
AsnNull nval,
AsnInt ival,
AsnAny anyval,
AsnVisibleString vsval,
ProtocolElem_Field1 pardval
} with {
variant "JSON: as value";
}
type record of AsnThing AsnStuff;
import from JsonTypes1 all;
type record OptionalUnions {
charstring dummy,
......
/******************************************************************************
* 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 JsonTypes1 {
import from JsonData all;
const integer c_imported_i :=11;
type enumerated Days { Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday };
type record R {
integer i,
charstring cs,
boolean b,
Days d
}
type record R2 {
R r,
float f
}
type record EmptyRec { }
type union A {
R r,
integer i,
boolean b,
float f
}
type record of universal charstring RoUCS;
type record of charstring RoCS;
type record of octetstring RoOS;
type record of integer RoI;
type record of verdicttype RoV;
type record of float RoF;
type integer IntArr[3];
type float FloatArr[3];
type universal charstring StrArr[4];
type record Date {
charstring month,
integer day_idx,
Days day_name
}
type record of Date Dates;
type record PhoneNumber {
integer country_prefix,
integer network_prefix,
integer local_number
} with {
variant(country_prefix) "JSON: name as CountryPrefix";
variant(network_prefix) "JSON: name as NetworkPrefix";
variant(local_number) "JSON : name as LocalNumber"
}
type record Profile0 {
charstring name,
PhoneNumber phone_no,
charstring email_addr optional,
Dates meetings optional
}
type record Profile {
charstring name,
PhoneNumber phone_no,
charstring email_addr optional,
Dates meetings optional
} with {
//variant(email_addr) "JSON : omit as null";
variant(meetings) "JSON:omit as null";
variant(phone_no) "JSON: name as phone";
variant(email_addr) "JSON: name as email";
}
type union CBA {
integer i_val,
Date date_val,
float f_val,
charstring cs_val
} with {
variant(date_val) "JSON:name as date";
variant(i_val) "JSON:name as int";
variant(f_val) "JSON:name as float";
variant(cs_val) "JSON:name as string";
}
type set Product {
charstring name,
float price optional,
hexstring code
} with {
variant(price) "JSON:omit as null"
}
type record KeywordFields {
integer a1,
integer a2,
integer a3,
integer a4,
integer a5,
integer a6,
integer a7,
integer a8,
integer a9,
integer a10,
integer a11
}
with {
variant(a1) "JSON: name as omit";
variant(a2) "JSON: name as as";
variant(a3) "JSON: name as null";
variant(a4) "JSON: name as name";
variant(a5) "JSON: name as value";
variant(a6) "JSON: name as default";
variant(a7) "JSON: name as extend";
variant(a8) "JSON: name as metainfo";
variant(a9) "JSON: name as for";
variant(a10) "JSON: name as unbound";
variant(a11) "JSON: name as JSON";
}
type union Thing {
integer ival,
float fval,
boolean bval,
enumerated { Tiny, Small, Average, Large, Huge } sizeval,
bitstring bsval,
octetstring osval,
union {
hexstring hsval,
record of charstring rocsval
} unival,
charstring csval,
universal charstring ucsval,
Product prodval,
record of integer roival,
record {
charstring name,
float price,
hexstring productID optional
} prod2val
} with {
variant "JSON:as value";
variant (prod2val.productID) "name as 'code'";
variant(unival) "JSON:as value";
}
type record of Thing Stuff;
type record RecDef {
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) "JSON : default(empty)";
variant(i) "JSON:default(-19)";
variant(f) "JSON:default(1.0e6)";
variant(size) "JSON:default(Tiny)";
variant(os) "JSON : default(1DE7)";
variant(ucs) "JSON:default(üres)";
variant(bs) "JSON:default (101)";
variant(hs) "JSON:default(DEAD)";
variant(vt) "JSON:default(fail)";
variant(b) "JSON:default(false)";
}
type record HasPardType {
ProtocolElem_Field1 pard,
boolean buul,
Price price
}
type union AsnThing {
AsnNull nval,
AsnInt ival,
AsnAny anyval,
AsnVisibleString vsval,
ProtocolElem_Field1 pardval
} with {
variant "JSON: as value";
}
type record of AsnThing AsnStuff;
} with {
encode "JSON";
}
......@@ -19,7 +19,7 @@ include $(TOPDIR)/Makefile.regression
TTCN3_LIB = ttcn3$(RT2_SUFFIX)$(DYNAMIC_SUFFIX)
TTCN3_MODULES = JsonTypes.ttcn JsonFunctions.ttcn AttributeTestcases.ttcn JsonTestcases.ttcn OtherTypes.ttcn SemanticCheck.ttcn Cbor.ttcn Bson.ttcn
TTCN3_MODULES = JsonTypes0.ttcn JsonTypes1.ttcn JsonFunctions.ttcn AttributeTestcases.ttcn JsonTestcases.ttcn OtherTypes.ttcn SemanticCheck.ttcn Cbor.ttcn Bson.ttcn
ifdef LEGACY_CODEC_HANDLING
TTCN3_MODULES += SemanticCheck2.ttcn
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment