Commit 572b7e7d authored by balaskoa's avatar balaskoa
Browse files

Header update in JSON of regression_test


Signed-off-by: default avatarbalaskoa <Jeno.Balasko@ericsson.com>
Change-Id: I151bc2a96fa02a116dffb1640cd4acb93b3f2825
parent 11c5b28a
/******************************************************************************
* 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
*
******************************************************************************/
module JsonBasicASN1EncDecTest1 {
import from JsonBasicASN1Types all;
......
--/////////////////////////////////////////////////////////////////////////////
-- 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
--
--/////////////////////////////////////////////////////////////////////////////
JsonBasicASN1Types DEFINITIONS
AUTOMATIC TAGS ::=
......
/******************************************************************************
* 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
*
******************************************************************************/
module JsonBasicAttributeTest {
type component CT {}
......@@ -14,6 +25,16 @@ function f_compare_bitstring(in bitstring pl_val, in bitstring pl_expected) {
//============= Types ===================
//=======================================
type enumerated E { e1,e2,e3 }
type enumerated Etext { One, Two, Three}
with {
variant "text 'One' as '1'"
variant "text 'Two' as '2'"
variant "text 'Three' as '3'"
}
//======= Record with one field =========
//no other attr than JSON
type record R0_json {
......@@ -38,10 +59,53 @@ type record R4_json {
//======= Record with more field =========
//==== Testcases ====
//type record R10_json {
// integer i optional,
// float f,
// E e
//} with { encode "JSON" }
//
//type record R11_json {
// integer i optional
//} with { encode "JSON"; variant(i) "JSON: omit as null"; }
//
//type record R12_json {
// integer i optional
//} with { encode "JSON"; variant(i) "JSON: name as Integer"; }
//
//type record R13_json {
// integer i optional
//} with { encode "JSON"; variant(i) "JSON: name as Integer"; variant(i) "JSON: omit as null";}
//
//type record R14_json {
// integer i optional
//} with { encode "JSON"; variant "JSON: as value";}
//=================================
//======= Testcases ===============
//=================================
//=== Enum ====
testcase tc_attr_enum_no_attr() runs on CT {
var E x := e2;
var bitstring expected := oct2bit(char2oct("\"e2\""));
var bitstring encoded := encvalue(x);
log(x);
log(bit2oct(encoded));
f_compare_bitstring(expected,encoded);
}
testcase tc_attr_enum_text_attr() runs on CT {
var Etext x := One;
var bitstring expected := oct2bit(char2oct("\"1\""));
var bitstring encoded := encvalue(x);
log(x);
log(bit2oct(encoded));
f_compare_bitstring(expected,encoded);
}
//No attribute
testcase tc_attr0_0() runs on CT {
testcase tc_rec_attr_no_attr_omit() runs on CT {
var R0_json x := { i:=omit }
var bitstring expected := oct2bit(char2oct("{}"));
var bitstring encoded := encvalue(x);
......@@ -50,7 +114,7 @@ testcase tc_attr0_0() runs on CT {
f_compare_bitstring(expected,encoded);
}
testcase tc_attr0_1() runs on CT {
testcase tc_rec_attr_no_attr_int() runs on CT {
var R0_json x := { i:= 1 }
var bitstring expected := oct2bit(char2oct("{\"i\":1}"));
var bitstring encoded := encvalue(x);
......@@ -60,7 +124,7 @@ testcase tc_attr0_1() runs on CT {
}
//Attribute: omit as null
testcase tc_attr1_0() runs on CT {
testcase tc_rec_attr_omit_as_null_omitvalue() runs on CT {
var R1_json x := { i:=omit }
var bitstring expected := oct2bit(char2oct("{\"i\":null}"));
var bitstring encoded := encvalue(x);
......@@ -69,7 +133,7 @@ testcase tc_attr1_0() runs on CT {
f_compare_bitstring(expected,encoded);
}
testcase tc_attr1_1() runs on CT {
testcase tc_rec_attr_omit_as_null_intvalue() runs on CT {
var R1_json x := { i:= 1 }
var bitstring expected := oct2bit(char2oct("{\"i\":1}"));
var bitstring encoded := encvalue(x);
......@@ -79,7 +143,7 @@ testcase tc_attr1_1() runs on CT {
}
//Attribute: name as
testcase tc_attr2_0() runs on CT {
testcase tc_rec_attr_name_as_omitvalue() runs on CT {
var R2_json x := { i:=omit }
var bitstring expected := oct2bit(char2oct("{}"));
var bitstring encoded := encvalue(x);
......@@ -88,7 +152,7 @@ testcase tc_attr2_0() runs on CT {
f_compare_bitstring(expected,encoded);
}
testcase tc_attr2_1() runs on CT {
testcase tc_rec_attr_name_as_intvalue() runs on CT {
var R2_json x := { i:= 1 }
var bitstring expected := oct2bit(char2oct("{\"Integer\":1}"));
var bitstring encoded := encvalue(x);
......@@ -98,7 +162,7 @@ testcase tc_attr2_1() runs on CT {
}
//Attribute: name as & omit as null
testcase tc_attr3_0() runs on CT {
testcase tc_rec_attr_name_as_and_omit_as_null_omitvalue() runs on CT {
var R3_json x := { i:=omit }
var bitstring expected := oct2bit(char2oct("{\"Integer\":null}"));
var bitstring encoded := encvalue(x);
......@@ -107,7 +171,7 @@ testcase tc_attr3_0() runs on CT {
f_compare_bitstring(expected,encoded);
}
testcase tc_attr3_1() runs on CT {
testcase tc_rec_attr_name_as_and_omit_as_null_intvalue() runs on CT {
var R3_json x := { i:= 1 }
var bitstring expected := oct2bit(char2oct("{\"Integer\":1}"));
var bitstring encoded := encvalue(x);
......@@ -117,7 +181,7 @@ testcase tc_attr3_1() runs on CT {
}
//Attribute: as value & omit as null
testcase tc_attr4_0() runs on CT {
testcase tc_rec_attr_as_value_and_omit_as_null_omitvalue() runs on CT {
var R4_json x := { i:= omit }
var bitstring expected := oct2bit(char2oct("null"));
var bitstring encoded := encvalue(x);
......@@ -125,7 +189,7 @@ testcase tc_attr4_0() runs on CT {
f_compare_bitstring(expected,encoded);
}
testcase tc_attr4_1() runs on CT {
testcase tc_rec_attr_as_value_and_omit_as_null_intvalue() runs on CT {
var R4_json x := { i:= 1 }
var bitstring expected := oct2bit(char2oct("1"));
var bitstring encoded := encvalue(x);
......@@ -134,16 +198,20 @@ testcase tc_attr4_1() runs on CT {
f_compare_bitstring(expected,encoded);
}
control {
execute(tc_attr0_0());
execute(tc_attr0_1());
execute(tc_attr1_0());
execute(tc_attr1_1());
execute(tc_attr2_0());
execute(tc_attr2_1());
execute(tc_attr3_0());
execute(tc_attr3_1());
execute(tc_attr4_0());
execute(tc_attr4_1());
execute(tc_attr_enum_no_attr());
execute(tc_attr_enum_text_attr());
execute(tc_rec_attr_no_attr_omit());
execute(tc_rec_attr_no_attr_int());
execute(tc_rec_attr_omit_as_null_omitvalue());
execute(tc_rec_attr_omit_as_null_intvalue());
execute(tc_rec_attr_name_as_omitvalue());
execute(tc_rec_attr_name_as_intvalue());
execute(tc_rec_attr_name_as_and_omit_as_null_omitvalue());
execute(tc_rec_attr_name_as_and_omit_as_null_intvalue());
execute(tc_rec_attr_as_value_and_omit_as_null_omitvalue());
execute(tc_rec_attr_as_value_and_omit_as_null_intvalue());
}
} with {
encode "JSON";
}
// The testcases checks if the encode funcions run and checks the result.
/******************************************************************************
* 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
*
******************************************************************************/
// The testcases check if the encode funcions run and check the result.
// The return value of encoding functions is bitstring
// Anytype is out of scope
//Status: cpp: compiled and run with 21 pass
......@@ -966,7 +978,7 @@ testcase tc_jsonBasic_encdec_anytype_i() runs on CT {
control {
execute( tc_jsonBasic_encdec_integer() );
execute( tc_jsonBasic_encdec_integer_big() );
execute(tc_jsonBasic_encdec_integer_big());
execute( tc_jsonBasic_encdec_float1() );
execute( tc_jsonBasic_encdec_float2() );
execute( tc_jsonBasic_encdec_float3() );
......
// The testcases checks if the encode and decode funcions run and checks the result.
/******************************************************************************
* 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
*
******************************************************************************/
// The testcases check if the encode and decode funcions run and check the result.
// The return value of the encoding functions is octetstring
// Anytype is out of scope
// Status: cpp: compiled and run with 14 pass
......@@ -57,6 +68,38 @@ testcase tc_jsonBasic_encdec_os_integer() runs on CT {
// }
}
testcase tc_jsonBasic_encdec_os_integer_big() runs on CT {
const I_json x := 2222222222222222222222222222222222;
var I_json y := 2222222222222222222222222222222222, z;
var octetstring os;
var octetstring expected := char2oct("2222222222222222222222222222222222");
log("expected:",expected);
os := f_json_enc_i2os(x);
f_compare_octetstring(os,expected);
os := f_json_enc_i2os(y);
f_compare_octetstring(os,expected);
//decode test:
z := f_json_dec_os2i(expected);
if ( y ==z ) {
setverdict(pass);
} else {
setverdict(fail);
}
// //Whitespace test
// expected := char2oct(" 2 3 4 ");
// log(expected);
//
// //decode test:
// z := f_json_dec_os2i(expected);
// if ( y ==z ) {
// setverdict(pass);
// } else {
// setverdict(fail);
// }
}
testcase tc_jsonBasic_encdec_os_float() runs on CT {
const F_json x := 2.0;
var F_json y := 2.0, z;
......@@ -534,6 +577,7 @@ testcase tc_jsonBasic_encdec_os_anytype_i() runs on CT {
control {
execute( tc_jsonBasic_encdec_os_integer() );
execute( tc_jsonBasic_encdec_os_integer_big() );
execute( tc_jsonBasic_encdec_os_float() );
execute( tc_jsonBasic_encdec_os_enum() );
execute( tc_jsonBasic_encdec_os_bitstring() );
......
/******************************************************************************
* 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
*
******************************************************************************/
module JsonBasicTypeAltstep {
//altstep as() {
......
/******************************************************************************
* 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
*
******************************************************************************/
module JsonBasicTypeBS {
type bitstring BS_json;
} with {
......
/******************************************************************************
* 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
*
******************************************************************************/
module JsonBasicTypeE {
type enumerated E_json {first, second}
} with {
......
/******************************************************************************
* 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
*
******************************************************************************/
module JsonBasicTypeF {
type float F_json;
} with {
......
/******************************************************************************
* 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
*
******************************************************************************/
module JsonBasicTypeFuncRef {
//function foonction(in charstring input) return charstring
......
/******************************************************************************
* 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
*
******************************************************************************/
module JsonBasicTypeHS {
type hexstring HS_json;
} with {
......
/******************************************************************************
* 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
*
******************************************************************************/
module JsonBasicTypeI {
type integer I_json;
} with {
......
/******************************************************************************
* 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
*
******************************************************************************/
module JsonBasicTypeOS {
type octetstring OS_json;
} with {
......
/******************************************************************************
* 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
*
******************************************************************************/
module JsonBasicTypes {
type integer I_json;
......
/******************************************************************************
* 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
*
******************************************************************************/
module JsonEncDecFunctions {
import from JsonBasicTypes all;
......
/******************************************************************************
* 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
*
******************************************************************************/
//Bug: Erroneous generated code
//Status: fixed.
module JsonRoUBug1 {
......
/******************************************************************************
* 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
*
******************************************************************************/
//The goal of this module is to check if all necessary import is present
module JsonTypeAny {
......
/******************************************************************************
* 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
*
******************************************************************************/
//The goal of this module is to check if all necessary import is present
//Status: no error
module JsonTypeAny2 {
......
/******************************************************************************
* 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
*
******************************************************************************/
module JsonTypeRec {
type record R {
integer i,
......
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