Commit cc1cb676 authored by balaskoa's avatar balaskoa
Browse files

Regression_Test_java/tempateCharstr copied from titan.core


Signed-off-by: default avatarbalaskoa <Jeno.Balasko@ericsson.com>
parent 8bc7612c
......@@ -21,9 +21,11 @@
"src/implicitOmit/config.cfg" #ok, 18 pass
"src/predefFunction/PreDef.cfg"
"src/recofOper/config.cfg" #62 pass + 2 tc moved to single_bugs.cfg
"src/templateCharstr/config.cfg"
"src/templateRecof/config.cfg" #ok 38 pass
"src/text2ttcn_nolegacy/text2ttcn_1.cfg"
#"src/text2ttcn/text2ttcn_1.cfg" #legacy mode
"src/templateRecof/config.cfg" #ok 38 pass
"src/ucharstrOper/config.cfg"
[EXECUTE]
......
/******************************************************************************
* Copyright (c) 2000-2019 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
* Godar, Marton
* Kovacs, Ferenc
* Raduly, Csaba
* Szabados, Kristof
* Szabo, Janos Zoltan – initial implementation
* Pandi, Krisztian
*
******************************************************************************/
module TtemplateCharstr {
type component templateCharstr_mycomp {};
type record templateCharstr_rec {
charstring x1,
charstring x2,
charstring x3 optional
}
with {
encode "JSON";
variant(x1) "JSON: name as first";
variant(x2) "JSON: name as second";
variant(x3) "JSON: name as third";
}
type record decmatch_rec {
integer i,
charstring s
}
with {
encode "JSON";
}
type record of integer decmatch_list
with {
encode "XML";
variant "list";
}
type union decmatch_uni {
integer i,
charstring s
}
with {
encode "RAW";
variant(i) "FIELDLENGTH(16)";
}
template templateCharstr_rec templateCharstr_tSpec :={ //specific values
x1:="00AA",
x2:="01AA",
x3:="10AA" };
template templateCharstr_rec templateCharstr_tList :={ //specific value and value list
x1:="00AA",
x2:=("01AA","01AB","11AC"),
x3:="10AA" };
template templateCharstr_rec templateCharstr_tComp :={ //specific value and compl. list
x1:="00AA",
x2:=complement ("11","0A","1BC0"),
x3:="10AA" };
template templateCharstr_rec templateCharstr_tOmit :={ //omitting values
x1:="00AA",
x2:="01AA",
x3:=omit } ;
template templateCharstr_rec templateCharstr_tAny :={ //specific and any value
x1:="00AA",
x2:="01AA",
x3:=? } ;
template templateCharstr_rec templateCharstr_tAnyorNone :={ //specific and AnyorNone value
x1:="00AA",
x2:="01AA",
x3:=* };
template templateCharstr_rec templateCharstr_tLength1 :={ //specific value and fix length
x1:="00AA",
x2:="01AA",
x3:=* length(3) };
template templateCharstr_rec templateCharstr_tLength2 :={ //specific value and length (range)
x1:="00AA",
x2:="01AA",
x3:=? length(2..4) };
template templateCharstr_rec templateCharstr_tLength3 :={ //specific value and length (range, infinity)
x1:="00AA",
x2:="01AA",
x3:=? length(2..infinity) };
template templateCharstr_rec templateCharstr_tIfpresent :={ //specific value and ifpresent
x1:="00AA",
x2:="01AA",
x3:="10AA" ifpresent };
template templateCharstr_rec templateCharstr_tLengthIfp :={ //specific value and fix length and ifpresent
x1:="00AA",
x2:="01AA",
x3:=? length(3) ifpresent};
template templateCharstr_rec templateCharstr_tAnyEl :={ //specific value and any element inside value
x1:="00AA",
x2:="01AA",
x3:= pattern "10?" } ;
template templateCharstr_rec templateCharstr_tAnyorNoneEl :={ //specific value and Any number of elements or none inside value
x1:="00AA",
x2:="01AA",
x3:= pattern "10*" };
template templateCharstr_rec templateCharstr_tRange1 :={ //specific value and Range
x1:="1",
x2:=("2" .."4"),
x3:="3" };
template templateCharstr_rec templateCharstr_tRange2 :={ //specific value and Range
x1:="1",
x2:=("2" .. "4"),
x3:="3" };
template templateCharstr_rec templateCharstr_tRange3 :={ //specific value and Range
x1:="1",
x2:=("3" .. int2char(127)),
x3:="3" };
template templateCharstr_rec templateCharstr_tRange4 :={ //specific value and Range
x1:="1",
x2:=(int2char(0) .. "4"),
x3:="3" };
template templateCharstr_rec templateCharstr_tRepeat := {
x1:= pattern "6#3", // precisely 3
x2:= pattern "6#(,)", // any number
x3:= pattern "6#(3)" }; // precisely 3
template templateCharstr_rec templateCharstr_tRepeatFull := {
x1:= pattern "6#(3,)", // at least 3
x2:= pattern "6#(,3)", // at most 3
x3:= pattern "6#(3,3)" }; // precisely 3
template templateCharstr_rec templateCharstr_tPattern := {
x1 := pattern "abc?xyz",
x2 := pattern @nocase "abc?xyz",
x3 := pattern @nocase "abc*xyz" };
template decmatch_uni decmatch_tUnion := { i := ? };
template decmatch_rec decmatch_tRecord := { i := (0..infinity), s := ? };
template templateCharstr_rec templateCharstr_tDecmatch := { // decoded content match
x1 := decmatch decmatch_list: { (1..10), (11..20), (21..30) },
x2 := decmatch decmatch_tUnion,
x3 := decmatch modifies decmatch_tRecord := { s := "abc" }
};
template templateCharstr_rec templateCharstr_tDecmatchSelfRef := { // decoded content match with self-reference
x1 := "a",
x2 := decmatch templateCharstr_tDecmatchSelfRef.x1,
x3 := decmatch templateCharstr_rec: { x1 := templateCharstr_tDecmatchSelfRef.x1, x2 := ?, x3 := * }
};
testcase templateCharstrSpec() runs on templateCharstr_mycomp {
var templateCharstr_rec x1,x2; //specific value
x1:={ x1:="00AA", x2:="01AA", x3:="10AA" };
x2:={ x1:="00BC", x2:="01AA", x3:="10AA" };
//match
if (match(x1,templateCharstr_tSpec)) {setverdict(pass);}
else {setverdict(fail);}
//no match
if (not(match(x2,templateCharstr_tSpec))) {setverdict(pass);}
else {setverdict(fail);}
}
testcase templateCharstrList() runs on templateCharstr_mycomp {
var templateCharstr_rec x1,x2,x3; //value list
x1:={ x1:="00AA", x2:="01AA", x3:="10AA" };
x2:={ x1:="00AA", x2:="00", x3:="10AA" };
x3:={ x1:="1D", x2:="01AA", x3:="10AA" };
//match
if (match(x1,templateCharstr_tList)) {setverdict(pass);}
else {setverdict(fail);}
//no match: out of list
if (not(match(x2,templateCharstr_tList))) {setverdict(pass);}
else {setverdict(fail);}
//no match: other field
if (not(match(x3,templateCharstr_tList))) {setverdict(pass);}
else {setverdict(fail);}
}
testcase templateCharstrComp() runs on templateCharstr_mycomp {
var templateCharstr_rec x1,x2,x3; //complemented list
x1:={ x1:="00AA", x2:="01AA", x3:="10AA" };
x2:={ x1:="00AA", x2:="0A", x3:="10AA" };
x3:={ x1:="11AA", x2:="01AA", x3:="10AA" };
//match
if (match(x1,templateCharstr_tComp)) {setverdict(pass);}
else {setverdict(fail);}
//no match: in the list
if (not(match(x2,templateCharstr_tComp))) {setverdict(pass);}
else {setverdict(fail);}
//no match: other field
if (not(match(x3,templateCharstr_tComp))) {setverdict(pass);}
else {setverdict(fail);}
}
testcase templateCharstrOmit() runs on templateCharstr_mycomp {
var templateCharstr_rec x1,x2,x3; //omitting value
x1:={ x1:="00AA", x2:="01AA", x3:=omit };
x2:={ x1:="00AA", x2:="01AA", x3:="AB" };
x3:={ x1:="00DE", x2:="01AA", x3:=omit };
//match
if (match(x1,templateCharstr_tOmit)) {setverdict(pass);}
else {setverdict(fail);}
//no match: not omitted
if (not(match(x2,templateCharstr_tOmit))) {setverdict(pass);}
else {setverdict(fail);}
//no match: other field
if (not(match(x3,templateCharstr_tOmit))) {setverdict(pass);}
else {setverdict(fail);}
}
testcase templateCharstrAny() runs on templateCharstr_mycomp {
var templateCharstr_rec x1,x2,x3; //any value
x1:={ x1:="00AA", x2:="01AA", x3:="ABCD" };
x2:={ x1:="00AA", x2:="01AA", x3:=omit };
x3:={ x1:="0A", x2:="01AA", x3:="ABCD" };
//match
if (match(x1,templateCharstr_tAny)) {setverdict(pass);}
else {setverdict(fail);}
//no match: field omitted
if (not(match(x2,templateCharstr_tAny))) {setverdict(pass);}
else {setverdict(fail);}
//no match: other field
if (not(match(x3,templateCharstr_tAny))) {setverdict(pass);}
else {setverdict(fail);}
}
testcase templateCharstrAnyorNone() runs on templateCharstr_mycomp {
var templateCharstr_rec x1,x2,x3; //AnyorNone value
x1:={ x1:="00AA", x2:="01AA", x3:=omit };
x2:={ x1:="00AA", x2:="01AA", x3:="10AB" };
x3:={ x1:="1C", x2:="01AA", x3:=omit };
//match: omitted
if (match(x1,templateCharstr_tAnyorNone)) {setverdict(pass);}
else {setverdict(fail);}
//match: value
if (match(x2,templateCharstr_tAnyorNone)) {setverdict(pass);}
else {setverdict(fail);}
//no match: other field
if (not(match(x3,templateCharstr_tAnyorNone))) {setverdict(pass);}
else {setverdict(fail);}
}
testcase templateCharstrLength1() runs on templateCharstr_mycomp {
var templateCharstr_rec x1,x2,x3,x4; //length (fix)
x1:={ x1:="00AA", x2:="01AA", x3:="abc" };
x2:={ x1:="00AA", x2:="01AA", x3:="abc" };
x3:={ x1:="00AA", x2:="01AA", x3:="1D" };
x4:={ x1:="001A", x2:="01AA", x3:="abc" };
//match: proper length
if (match(x1,templateCharstr_tLength1)) {setverdict(pass);}
else {setverdict(fail);}
//match: omitted
if (match(x2,templateCharstr_tLength1)) {setverdict(pass);}
else {setverdict(fail);}
// no match: not proper length
if (not(match(x3,templateCharstr_tLength1))) {setverdict(pass);}
else {setverdict(fail);}
//no match: other field
if (not(match(x4,templateCharstr_tLength1))) {setverdict(pass);}
else {setverdict(fail);}
}
testcase templateCharstrLength2() runs on templateCharstr_mycomp {
var templateCharstr_rec x1,x2,x3; //length (range)
x1:={ x1:="00AA", x2:="01AA", x3:="abcd" };
x2:={ x1:="00AA", x2:="01AA", x3:="a" };
x3:={ x1:="001A", x2:="01AA", x3:="abc" };
//match
if (match(x1,templateCharstr_tLength2)) {setverdict(pass);}
else {setverdict(fail);}
// no match: not proper length
if (not(match(x2,templateCharstr_tLength2))) {setverdict(pass);}
else {setverdict(fail);}
//no match: other field
if (not(match(x3,templateCharstr_tLength2))) {setverdict(pass);}
else {setverdict(fail);}
}
testcase templateCharstrLength3() runs on templateCharstr_mycomp {
var templateCharstr_rec x1,x2,x3; //length (range, infinity)
x1:={ x1:="00AA", x2:="01AA", x3:="abcd" };
x2:={ x1:="00AA", x2:="01AA", x3:="a" };
x3:={ x1:="001A", x2:="01AA", x3:="abc" };
//match
if (match(x1,templateCharstr_tLength3)) {setverdict(pass);}
else {setverdict(fail);}
// no match: not proper length
if (not(match(x2,templateCharstr_tLength3))) {setverdict(pass);}
else {setverdict(fail);}
//no match: other field
if (not(match(x3,templateCharstr_tLength3))) {setverdict(pass);}
else {setverdict(fail);}
}
testcase templateCharstrIfpresent() runs on templateCharstr_mycomp {
var templateCharstr_rec x1,x2,x3,x4; //ifpresent
x1:={ x1:="00AA", x2:="01AA", x3:="10AA" };
x2:={ x1:="00AA", x2:="01AA", x3:=omit };
x3:={ x1:="00AA", x2:="01AA", x3:="00AA" };
x4:={ x1:="00", x2:="01AA", x3:=omit };
//match: present and match
if (match(x1,templateCharstr_tIfpresent)) {setverdict(pass);}
else {setverdict(fail);}
//match: not present
if (match(x2,templateCharstr_tIfpresent)) {setverdict(pass);}
else {setverdict(fail);}
//no match: present and not match
if (not(match(x3,templateCharstr_tIfpresent))) {setverdict(pass);}
else {setverdict(fail);}
//no match: other field
if (not(match(x4,templateCharstr_tIfpresent))) {setverdict(pass);}
else {setverdict(fail);}
}
testcase templateCharstrLengthIfp() runs on templateCharstr_mycomp {
var templateCharstr_rec x1,x2,x3,x4; //length (fix), ifpresent
x1:={ x1:="00AA", x2:="01AA", x3:="abc" };
x2:={ x1:="00AA", x2:="01AA", x3:="abc" };
x3:={ x1:="00AA", x2:="01AA", x3:="1D" };
x4:={ x1:="001A", x2:="01AA", x3:="abc" };
//match: proper length
if (match(x1,templateCharstr_tLengthIfp)) {setverdict(pass);}
else {setverdict(fail);}
//match: omitted
if (match(x2,templateCharstr_tLengthIfp)) {setverdict(pass);}
else {setverdict(fail);}
// no match: not proper length
if (not(match(x3,templateCharstr_tLengthIfp))) {setverdict(pass);}
else {setverdict(fail);}
//no match: other field
if (not(match(x4,templateCharstr_tLengthIfp))) {setverdict(pass);}
else {setverdict(fail);}
}
testcase templateCharstrAnyEl() runs on templateCharstr_mycomp {
var templateCharstr_rec x1,x2,x3,x4,x5; //any element
x1:={ x1:="00AA", x2:="01AA", x3:="10a" };
x2:={ x1:="00AA", x2:="01AA", x3:="10" };
x3:={ x1:="00AA", x2:="01AA", x3:="10Aa" };
x4:={ x1:="00AA", x2:="01AA", x3:="12A" };
x5:={ x1:="0A", x2:="01AA", x3:="10a" };
//match
if (match(x1,templateCharstr_tAnyEl)) {setverdict(pass);}
else {setverdict(fail);}
//no match: no element
if (not(match(x2,templateCharstr_tAnyEl))) {setverdict(pass);}
else {setverdict(fail);}
//no match: two element
if (not(match(x3,templateCharstr_tAnyEl))) {setverdict(pass);}
else {setverdict(fail);}
//no match: wrong element
if (not(match(x4,templateCharstr_tAnyEl))) {setverdict(pass);}
else {setverdict(fail);}
//no match: other field
if (not(match(x5,templateCharstr_tAnyEl))) {setverdict(pass);}
else {setverdict(fail);}
}
testcase templateCharstrAnyorNoneEl() runs on templateCharstr_mycomp {
var templateCharstr_rec x1,x2,x3,x4,x5; //Any number of elements or none
x1:={ x1:="00AA", x2:="01AA", x3:="10" };
x2:={ x1:="00AA", x2:="01AA", x3:="10k" };
x3:={ x1:="00AA", x2:="01AA", x3:="10Aa" };
x4:={ x1:="00AA", x2:="01AA", x3:="11a" };
x5:={ x1:="1A", x2:="01AA", x3:="10a" };
//match: no element
if (match(x1,templateCharstr_tAnyorNoneEl)) {setverdict(pass);}
else {setverdict(fail);}
//match: one element
if (match(x2,templateCharstr_tAnyorNoneEl)) {setverdict(pass);}
else {setverdict(fail);}
//match: two element
if (match(x3,templateCharstr_tAnyorNoneEl)) {setverdict(pass);}
else {setverdict(fail);}
//no match: wrong element
if (not(match(x4,templateCharstr_tAnyorNoneEl))) {setverdict(pass);}
else {setverdict(fail);}
//no match: other field
if (not(match(x5,templateCharstr_tAnyorNoneEl))) {setverdict(pass);}
else {setverdict(fail);}
}
testcase templateCharstrRange1() runs on templateCharstr_mycomp {
var templateCharstr_rec x1,x2,x3; //Range ( .. )
x1:={ x1:="1", x2:="2", x3:="3" };
x2:={ x1:="1", x2:="5", x3:="3" };
x3:={ x1:="2", x2:="2", x3:="3" };
//match
if (match(x1,templateCharstr_tRange1)) {setverdict(pass);}
else {setverdict(fail);}
//no match: out of range
if (not(match(x2,templateCharstr_tRange1))) {setverdict(pass);}
else {setverdict(fail);}
//no match: other field
if (not(match(x3,templateCharstr_tRange1))) {setverdict(pass);}
else {setverdict(fail);}
}
testcase templateCharstrRange2() runs on templateCharstr_mycomp {
var templateCharstr_rec x1,x2,x3; //Range ( to )
x1:={ x1:="1", x2:="2", x3:="3" };
x2:={ x1:="1", x2:="5", x3:="3"};
x3:={ x1:="2", x2:="2", x3:="3" };
//match
if (match(x1,templateCharstr_tRange2)) {setverdict(pass);}
else {setverdict(fail);}
//no match: out of range
if (not(match(x2,templateCharstr_tRange2))) {setverdict(pass);}
else {setverdict(fail);}
//no match: other field
if (not(match(x3,templateCharstr_tRange2))) {setverdict(pass);}
else {setverdict(fail);}
}
testcase templateCharstrRange3() runs on templateCharstr_mycomp {
var templateCharstr_rec x1,x2,x3; //Range, with infinity
x1:={ x1:="1", x2:="8", x3:="3" };
x2:={ x1:="1", x2:="2", x3:="3" };
x3:={ x1:="2", x2:="2", x3:="3" };
//match
if (match(x1,templateCharstr_tRange3)) {setverdict(pass);}
else {setverdict(fail);}
//no match: out of range
if (not(match(x2,templateCharstr_tRange3))) {setverdict(pass);}
else {setverdict(fail);}
//no match: other field
if (not(match(x3,templateCharstr_tRange3))) {setverdict(pass);}
else {setverdict(fail);}
}
testcase templateCharstrRange4() runs on templateCharstr_mycomp {
var templateCharstr_rec x1,x2,x3; //Range with - infinity
x1:={ x1:="1", x2:="2", x3:="3" };
x2:={ x1:="1", x2:="5", x3:="3" };
x3:={ x1:="2", x2:="2", x3:="3" };
//match
if (match(x1,templateCharstr_tRange4)) {setverdict(pass);}
else {setverdict(fail);}
//no match: out of range
if (not(match(x2,templateCharstr_tRange4))) {setverdict(pass);}
else {setverdict(fail);}
//no match: other field
if (not(match(x3,templateCharstr_tRange4))) {setverdict(pass);}
else {setverdict(fail);}
}
type record templateCharstr_myrec {
charstring f1 optional,
charstring f2 optional
}
const templateCharstr_myrec mr := {
f1 := "b",
f2 := "a"
}
type component templateCharstr_mycomp2 {
const charstring x1 := "";
var charstring x2 := "";
const charstring x3 := "x";
var charstring x4 := "x";
}
function tryPatternReferenceWithOptionalField(in templateCharstr_myrec p) runs on templateCharstr_mycomp2
{ // regression test for TR 909
template charstring piecemeal := pattern "{p.f1}{p.f2}r";
if (match("bar", piecemeal)) { setverdict(pass); }
else { setverdict(fail); }
if (match("r", piecemeal)) { setverdict(fail); }
else { setverdict(pass); }
var template charstring piecemealv := pattern "{p.f1}{p.f2}r";
if (match("bar", piecemealv)) { setverdict(pass); }
else { setverdict(fail); }
if (match("r", piecemealv)) { setverdict(fail); }
else { setverdict(pass); }
}
testcase templateCharstrEmptyPattern() runs on templateCharstr_mycomp2
{
if (match("", pattern "")) { setverdict(pass); }
else { setverdict(fail); }
if (not match("x", pattern "{x1}{x2}")) { setverdict(pass); }
else { setverdict(fail); }
if (match("xxx", pattern "{x3}x{x4}")) { setverdict(pass); }
else { setverdict(fail); }
tryPatternReferenceWithOptionalField(mr);
}
testcase templateCharstrRepeat() runs on templateCharstr_mycomp {
var templateCharstr_rec x1,x2,x3,x4; //repeat
x1:={ x1:="666", x2:="", x3:="666" };
x2:={ x1:="6" , x2:="", x3:="666" };
x3:={ x1:="666", x2:="", x3:="6666" };
x4:={ x1:="666", x2:="6 6 6", x3:="666" };
//match
if (match(x1,templateCharstr_tRepeat)) {setverdict(pass);}
else {setverdict(fail);}
//no match
if (not(match(x2,templateCharstr_tRepeat))) {setverdict(pass);}
else {setverdict(fail);}
if (not(match(x3,templateCharstr_tRepeat))) {setverdict(pass);}
else {setverdict(fail);}
if (not(match(x4,templateCharstr_tRepeat))) {setverdict(pass);}
else {setverdict(fail);}
}
testcase templateCharstrRepeatFull() runs on templateCharstr_mycomp {
var templateCharstr_rec x0,x1,x2,x3,x4; //repeat
x0:={ x1:="666", x2:="", x3:="666" }; // shortest possible
x1:={ x1:="6666", x2:="666", x3:="666" }; // just over
x2:={ x1:="6" , x2:="", x3:="666" }; // fail first
x3:={ x1:="666", x2:="6666", x3:="6666" }; // fail second
x4:={ x1:="666", x2:="", x3:="6" }; // fail third
//match
if (match(x0,templateCharstr_tRepeatFull)) {setverdict(pass);}
else {setverdict(fail);}
if (match(x1,templateCharstr_tRepeatFull)) {setverdict(pass);}
else {setverdict(fail);}
//no match
if (not(match(x2,templateCharstr_tRepeatFull))) {setverdict(pass);}
else {setverdict(fail);}
if (not(match(x3,templateCharstr_tRepeatFull))) {setverdict(pass);}
else {setverdict(fail);}
if (not(match(x4,templateCharstr_tRepeatFull))) {setverdict(pass);}
else {setverdict(fail);}
}
testcase templateCharstrPattern() runs on templateCharstr_mycomp {
var templateCharstr_rec x0, x1, x2, x3, x4; // pattern
x0 := { x1 := "abc,xyz", x2 := "abc1xyz", x3 := "abcxyz" };
x1 := { x1 := "abcpxyz", x2 := "abcPxyz", x3 := "abc123abcJKL.? \txyz" };
x2 := { x1 := "abcxyz", x2 := "abcPxyz", x3 := "abc123xyz" }; // fail first
x3 := { x1 := "abcpxyz", x2 := "abc123xyz", x3 := "abc123xyz" }; // fail second
x4 := { x1 := "abcpxyz", x2 := "abcPxyz", x3 := "abc123xy z" }; // fail third
// match
if (match(x0, templateCharstr_tPattern)) { setverdict(pass); }
else { setverdict(fail); }
if (match(x1, templateCharstr_tPattern)) { setverdict(pass); }
else { setverdict(fail); }
// not match
if (not match(x2, templateCharstr_tPattern)) { setverdict(pass); }
else { setverdict(fail); }
if (not match(x3, templateCharstr_tPattern)) { setverdict(pass); }
else { setverdict(fail); }
if (not match(x4, templateCharstr_tPattern)) { setverdict(pass); }
else { setverdict(fail); }