Commit 8f07cad0 authored by balaskoa's avatar balaskoa
Browse files

New testcases have been mapped from titan.core 8


Signed-off-by: default avatarbalaskoa <Jeno.Balasko@ericsson.com>
parent a02dcf16
......@@ -39,6 +39,12 @@
<ExcludeFromBuild>true</ExcludeFromBuild>
</FileProperties>
</FileResource>
<FileResource>
<FilePath>src/functionSubref/TvalueofSubref.ttcn</FilePath>
<FileProperties>
<ExcludeFromBuild>true</ExcludeFromBuild>
</FileProperties>
</FileResource>
</FileProperties>
<FolderProperties>
<FolderResource>
......
......@@ -31,7 +31,10 @@
#TbitstrOper.tc__value_list_bs #fails
#cstr_content.tc_unichar_utf8_mp2
#TcharstrOper.tc_altstep_cs_idx # bring back the uncommented test!
TmultipleRedirects.commMessageDecodedValueRedirect #error JSON encode is missing
#TmultipleRedirects.commMessageDecodedValueRedirect #error JSON encode is missing
#TvalueofSubref.control #the file excluded!!
#TfunctionSubref.tc_func_subref_parameter
#TpardTemplateSubref.control # 6 error
[LOGGING]
......
......@@ -122,6 +122,12 @@ EnumDefBitHexOct
#TfloatOperSpecial
#functionReference:
#FuncRef
#cont here...
#functionSubref:
TfunctionSubref #22 pass, 1 error (see in single_bugs.cfg)
#TpardTemplateSubref #1 pass, 6 error (see in single_bugs.cfg)
#json (There are testcases commented out in it!! In preinit of JsonTypes it stops with exception)
#AttributeTestcases.control
......
File mode changed from 100755 to 100644
/******************************************************************************
* 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
*
******************************************************************************/
// This module contains tests for using subreferences (field names and array indexes) on the
// return values of function calls.
module TfunctionSubref {
/* * * * Types * * * */
type record Rec {
integer num,
charstring str
}
type record of integer RoI;
type union Uni {
integer i,
float f,
boolean b,
bitstring bs,
hexstring hs,
octetstring os,
charstring cs,
universal charstring ucs,
verdicttype vt,
enumerated { Small, Medium, Large } size
}
type octetstring Arr[4];
type record of Uni RoUni;
type set Complex {
Rec rec,
RoI roi,
RoUni unis
}
type port PT message {
inout integer, octetstring
}
with { extension "internal" };
type component CT {
timer t;
port PT pt;
}
/* * * * Tested functions * * * */
function f_rec(in Rec x) return Rec { return x; }
function f_roi(in RoI x) return RoI { return x; }
function f_uni(in Uni x) return Uni { return x; }
function f_arr(in Arr x) return Arr { return x; }
function f_complex(in Complex x) return Complex { return x; }
function f_rec_temp(in template Rec x) return template Rec { return x; }
function f_roi_temp(in template RoI x) return template RoI { return x; }
function f_uni_temp(in template Uni x) return template Uni { return x; }
function f_arr_temp(in template Arr x) return template Arr { return x; }
function f_complex_temp(in template Complex x) return template Complex { return x; }
/* * * * Helper functions for certain test cases * * * */
function f_test(in charstring p1, in integer p2, in boolean p3, in octetstring p4)
{
if (p1 == c_rec.str) { setverdict(pass); }
else { setverdict(fail, "Expected: ", c_rec.str, ", got: ", p1); }
if (p2 == c_roi[0]) { setverdict(pass); }
else { setverdict(fail, "Expected: ", c_roi[0], ", got: ", p2); }
if (p3 == c_unis[2].b) { setverdict(pass); }
else { setverdict(fail, "Expected: ", c_unis[2].b, ", got: ", p3); }
if (p4 == c_arr[1]) { setverdict(pass); }
else { setverdict(fail, "Expected: ", c_arr[1], ", got: ", p4); }
}
function f_test_temp(in template charstring p1, in template integer p2,
in template boolean p3, in template octetstring p4)
{
if (log2str(p1) == log2str(t_rec.str)) { setverdict(pass); }
else { setverdict(fail, "Expected: ", t_rec.str, ", got: ", p1); }
if (log2str(p2) == log2str(t_roi[0])) { setverdict(pass); }
else { setverdict(fail, "Expected: ", t_roi[0], ", got: ", p2); }
if (log2str(p3) == log2str(t_unis[2].b)) { setverdict(pass); }
else { setverdict(fail, "Expected: ", t_unis[2].b, ", got: ", p3); }
if (log2str(p4) == log2str(t_arr[1])) { setverdict(pass); }
else { setverdict(fail, "Expected: ", t_arr[1], ", got: ", p4); }
}
external function ef_enc_int(in integer x) return octetstring
with { extension "prototype(convert) encode(JSON)" };
external function ef_enc_oct(in octetstring x) return octetstring
with { extension "prototype(convert) encode(JSON)" };
altstep as_ct() runs on CT
{
var integer bad_int;
var octetstring bad_os;
[] pt.receive(integer:?) -> value bad_int {
setverdict(fail, "Expected octetstring value instead of ", bad_int);
}
[] pt.receive(octetstring:?) -> value bad_os {
setverdict(fail, "Expected integer value instead of ", bad_os);
}
[] t.timeout {
setverdict(inconc, "Receive timed out");
}
}
/* * * * Constants and templates * * * */
const Rec c_rec := { num := 3, str := "a0" };
const RoI c_roi := { 1, 2, 4, 8, 16 };
const RoUni c_unis := { { i := -6 }, { f := 0.5 }, { b := true }, { bs := '1101'B }, { hs := '3D7'H },
{ os := '44A1'O }, { cs := "abc" }, { ucs := "víz" }, { vt := error }, { size := Small } };
const Arr c_arr := { '01'O, 'DE'O, 'ABBA'O, '1234EEFF'O };
template Rec t_rec := { num := (0..100), str := pattern "a*b" };
template RoI t_roi := { ?, 0, ((-10..-1), (1..10)) };
template RoUni t_unis := { { i := (0..infinity) }, { f := (-1.0..1.0) }, { b := ? }, { bs := ? length (1..4) },
{ hs := '12345FF'H }, { os := ('0000'O, 'FFFF'O) }, { cs := ("a".."z") length (5) }, { ucs := "víz" },
{ vt := ? }, { size := (Small, Large) } };
template Arr t_arr := { ? length (2), ?, 'FEFEFE'O, 'DEADBEEF'O };
/* * * * Test cases * * * */
testcase tc_func_subref_var_assign() runs on CT
{
var integer x1 := f_rec(c_rec).num;
var integer x2 := f_roi(c_roi)[4];
var integer x3 := f_uni(c_unis[0]).i;
var charstring str1 := f_rec(c_rec).str;
var charstring str2 := f_uni(c_unis[6]).cs;
var octetstring os := f_arr(c_arr)[1];
if (x1 == c_rec.num) { setverdict(pass); }
else { setverdict(fail, "Expected: ", c_rec.num, ", got: ", x1); }
if (x2 == c_roi[4]) { setverdict(pass); }
else { setverdict(fail, "Expected: ", c_roi[4], ", got: ", x2); }
if (x3 == c_unis[0].i) { setverdict(pass); }
else { setverdict(fail, "Expected: ", c_unis[0].i, ", got: ", x3); }
if (str1 == c_rec.str) { setverdict(pass); }
else { setverdict(fail, "Expected: ", c_rec.str, ", got: ", str1); }
if (str2 == c_unis[6].cs) { setverdict(pass); }
else { setverdict(fail, "Expected: ", c_unis[6].cs, ", got: ", str2); }
if (os == c_arr[1]) { setverdict(pass); }
else { setverdict(fail, "Expected: ", c_roi[1], ", got: ", os); }
}
testcase tc_func_subref_equality() runs on CT
{
if (f_rec(c_rec).str == c_rec.str) { setverdict(pass); }
else { setverdict(fail, "Expected: ", c_rec.str, ", got: ", f_rec(c_rec).str); }
if (f_roi(c_roi)[2] == c_roi[2]) { setverdict(pass); }
else { setverdict(fail, "Expected: ", c_roi[2], ", got: ", f_roi(c_roi)[2]); }
if (f_uni(c_unis[3]).bs == c_unis[3].bs) { setverdict(pass); }
else { setverdict(fail, "Expected: ", c_unis[3].bs, ", got: ", f_uni(c_unis[3]).bs); }
if (f_arr(c_arr)[3] == c_arr[3]) { setverdict(pass); }
else { setverdict(fail, "Expected: ", c_arr[3], ", got: ", f_arr(c_arr)[3]); }
if (f_rec(c_rec).num != 100) { setverdict(pass); }
else { setverdict(fail, "Expected anything other than 100"); }
if (f_roi(c_roi)[1] != 16) { setverdict(pass); }
else { setverdict(fail, "Expected anything other than 16"); }
if (f_uni(c_unis[8]).vt != pass) { setverdict(pass); }
else { setverdict(fail, "Expected anything other than pass"); }
if (f_arr(c_arr)[0] != 'DE'O) { setverdict(pass); }
else { setverdict(fail, "Expected anything other than 'DE'O"); }
}
testcase tc_func_subref_bound_and_present() runs on CT
{
if (isbound(f_rec(c_rec).str)) { setverdict(pass); }
else { setverdict(fail, "Expected bound record field"); }
if (isbound(f_roi(c_roi)[2])) { setverdict(pass); }
else { setverdict(fail, "Expected bound record of element"); }
if (isbound(f_uni(c_unis[2]).b)) { setverdict(pass); }
else { setverdict(fail, "Expected bound union alternative"); }
if (isbound(f_arr(c_arr)[2])) { setverdict(pass); }
else { setverdict(fail, "Expected bound array element"); }
if (ispresent(f_uni(c_unis[9]).size)) { setverdict(pass); }
else { setverdict(fail, "Expected present union alternative"); }
}
testcase tc_func_subref_math_expr() runs on CT
{
var integer int_expr := -f_rec(c_rec).num + f_roi(c_roi)[3] * f_uni(c_unis[0]).i;
var integer int_expr_e := -c_rec.num + c_roi[3] * c_unis[0].i;
var float float_expr := 4.0 / f_uni(c_unis[1]).f;
var float float_expr_e := 4.0 / c_unis[1].f;
if (int_expr == int_expr_e) { setverdict(pass); }
else { setverdict(fail, "Expected: ", int_expr_e, ", got: ", int_expr); }
if (float_expr == float_expr_e) { setverdict(pass); }
else { setverdict(fail, "Expected: ", float_expr_e, ", got: ", float_expr); }
}
testcase tc_func_subref_bool_expr() runs on CT
{
var boolean bool_expr := (not f_uni(c_unis[2]).b) or (f_rec(c_rec).num > 0 and
f_roi(c_roi)[2] < 10 xor f_uni(c_unis[9]).size >= Medium);
var boolean bool_expr_e := (not c_unis[2].b) or (c_rec.num > 0 and
c_roi[2] < 10 xor c_unis[9].size >= Medium);
if (bool_expr == bool_expr_e) { setverdict(pass); }
else { setverdict(fail, "Expected: ", bool_expr_e, ", got: ", bool_expr); }
}
testcase tc_func_subref_binary_expr() runs on CT
{
var bitstring bs_expr := f_uni(c_unis[3]).bs >> f_roi(c_roi)[1];
var bitstring bs_expr_e := c_unis[3].bs >> c_roi[1];
var hexstring hs_expr := f_uni(c_unis[4]).hs <@ f_rec(c_rec).num;
var hexstring hs_expr_e := c_unis[4].hs <@ c_rec.num;
var octetstring os_expr := f_uni(c_unis[5]).os and4b (not4b f_arr(c_arr)[2]);
var octetstring os_expr_e := c_unis[5].os and4b (not4b c_arr[2]);
if (bs_expr == bs_expr_e) { setverdict(pass); }
else { setverdict(fail, "Expected: ", bs_expr_e, ", got: ", bs_expr); }
if (hs_expr == hs_expr_e) { setverdict(pass); }
else { setverdict(fail, "Expected: ", hs_expr_e, ", got: ", hs_expr); }
if (os_expr == os_expr_e) { setverdict(pass); }
else { setverdict(fail, "Expected: ", os_expr_e, ", got: ", os_expr); }
}
testcase tc_func_subref_str_concat() runs on CT
{
var bitstring bs_expr := f_uni(c_unis[3]).bs & f_uni(c_unis[3]).bs;
var bitstring bs_expr_e := c_unis[3].bs & c_unis[3].bs;
var hexstring hs_expr := 'FF'H & f_uni(c_unis[4]).hs & 'FF'H;
var hexstring hs_expr_e := 'FF'H & c_unis[4].hs & 'FF'H;
var octetstring os_expr := f_uni(c_unis[5]).os & f_arr(c_arr)[3];
var octetstring os_expr_e := c_unis[5].os & c_arr[3];
var charstring cs_expr := f_uni(c_unis[6]).cs & " " & f_rec(c_rec).str;
var charstring cs_expr_e := c_unis[6].cs & " " & c_rec.str;
var universal charstring ucs_expr := "x" & f_uni(c_unis[7]).ucs & "x";
var universal charstring ucs_expr_e := "x" & c_unis[7].ucs & "x";
if (bs_expr == bs_expr_e) { setverdict(pass); }
else { setverdict(fail, "Expected: ", bs_expr_e, ", got: ", bs_expr); }
if (hs_expr == hs_expr_e) { setverdict(pass); }
else { setverdict(fail, "Expected: ", hs_expr_e, ", got: ", hs_expr); }
if (os_expr == os_expr_e) { setverdict(pass); }
else { setverdict(fail, "Expected: ", os_expr_e, ", got: ", os_expr); }
if (cs_expr == cs_expr_e) { setverdict(pass); }
else { setverdict(fail, "Expected: ", cs_expr_e, ", got: ", cs_expr); }
if (ucs_expr == ucs_expr_e) { setverdict(pass); }
else { setverdict(fail, "Expected: ", ucs_expr_e, ", got: ", ucs_expr); }
}
testcase tc_func_subref_str_length() runs on CT
{
if (lengthof(f_uni(c_unis[3]).bs) == lengthof(c_unis[3].bs)) { setverdict(pass); }
else { setverdict(fail, "Expected: ", lengthof(c_unis[3].bs), ", got: ", lengthof(f_uni(c_unis[3]).bs)); }
if (lengthof(f_uni(c_unis[4]).hs) == lengthof(c_unis[4].hs)) { setverdict(pass); }
else { setverdict(fail, "Expected: ", lengthof(c_unis[4].hs), ", got: ", lengthof(f_uni(c_unis[4]).hs)); }
if (lengthof(f_uni(c_unis[5]).os) == lengthof(c_unis[5].os)) { setverdict(pass); }
else { setverdict(fail, "Expected: ", lengthof(c_unis[5].os), ", got: ", lengthof(f_uni(c_unis[5]).os)); }
if (lengthof(f_arr(c_arr)[1]) == lengthof(c_arr[1])) { setverdict(pass); }
else { setverdict(fail, "Expected: ", lengthof(c_arr[1]), ", got: ", lengthof(f_arr(c_arr)[1])); }
if (lengthof(f_uni(c_unis[6]).cs) == lengthof(c_unis[6].cs)) { setverdict(pass); }
else { setverdict(fail, "Expected: ", lengthof(c_unis[6].cs), ", got: ", lengthof(f_uni(c_unis[6]).cs)); }
if (lengthof(f_rec(c_rec).str) == lengthof(c_rec.str)) { setverdict(pass); }
else { setverdict(fail, "Expected: ", lengthof(c_rec.str), ", got: ", lengthof(f_rec(c_rec).str)); }
if (lengthof(f_uni(c_unis[7]).ucs) == lengthof(c_unis[7].ucs)) { setverdict(pass); }
else { setverdict(fail, "Expected: ", lengthof(c_unis[7].ucs), ", got: ", lengthof(f_uni(c_unis[7]).ucs)); }
}
testcase tc_func_subref_str_index() runs on CT
{
if (f_uni(c_unis[3]).bs[2] == c_unis[3].bs[2]) { setverdict(pass); }
else { setverdict(fail, "Expected: ", c_unis[3].bs[2], ", got: ", f_uni(c_unis[3]).bs[2]); }
if (f_uni(c_unis[4]).hs[2] == c_unis[4].hs[2]) { setverdict(pass); }
else { setverdict(fail, "Expected: ", c_unis[4].hs[2], ", got: ", f_uni(c_unis[4]).hs[2]); }
if (f_uni(c_unis[5]).os[1] == c_unis[5].os[1]) { setverdict(pass); }
else { setverdict(fail, "Expected: ", c_unis[5].os[1], ", got: ", f_uni(c_unis[5]).os[1]); }
if (f_arr(c_arr)[2][1] == c_arr[2][1]) { setverdict(pass); }
else { setverdict(fail, "Expected: ", c_arr[2][1], ", got: ", f_arr(c_arr)[2][1]); }
if (f_uni(c_unis[6]).cs[2] == c_unis[6].cs[2]) { setverdict(pass); }
else { setverdict(fail, "Expected: ", c_unis[6].cs[2], ", got: ", f_uni(c_unis[6]).cs[2]); }
if (f_rec(c_rec).str[0] == c_rec.str[0]) { setverdict(pass); }
else { setverdict(fail, "Expected: ", c_rec.str[0], ", got: ", f_rec(c_rec).str[0]); }
if (f_uni(c_unis[7]).ucs[2] == c_unis[7].ucs[2]) { setverdict(pass); }
else { setverdict(fail, "Expected: ", c_unis[7].ucs[2], ", got: ", f_uni(c_unis[7]).ucs[2]); }
}
testcase tc_func_subref_log() runs on CT
{
var charstring sep := " | ";
var charstring log_str := log2str(f_rec(c_rec).str, sep, f_roi(c_roi)[3], sep, f_uni(c_unis[9]).size,
sep, f_arr(c_arr)[0]);
var charstring log_str_e := log2str(c_rec.str, sep, c_roi[3], sep, c_unis[9].size, sep, c_arr[0]);
if (log_str == log_str_e) { setverdict(pass); }
else { setverdict(fail, "Expected: ", log_str_e, ", got: ", log_str); }
log(f_rec(c_rec).str,f_roi(c_roi)[3], f_uni(c_unis[9]).size, f_arr(c_arr)[0]);
}
testcase tc_func_subref_structure() runs on CT
{
var Rec rec1 := { num := f_rec(c_rec).num, str := f_rec(c_rec).str }; // == c_rec
var Rec rec2 := { f_roi(c_roi)[1], f_uni(c_unis[6]).cs };
var Rec rec2_e := { c_roi[1], c_unis[6].cs };
var RoI roi := { f_uni(c_unis[0]).i, 91, f_roi(c_roi)[3], 0 };
var RoI roi_e := { c_unis[0].i, 91, c_roi[3], 0 };
var Uni uni := { vt := f_uni(c_unis[8]).vt }; // == c_unis[8]
var Arr arr := { [0] := f_arr(c_arr)[0], [1] := f_arr(c_arr)[1],
[2] := f_arr(c_arr)[2], [3] := f_arr(c_arr)[3] }; // == c_arr
if (rec1 == c_rec) { setverdict(pass); }
else { setverdict(fail, "Expected: ", c_rec, ", got: ", rec1); }
if (rec2 == rec2_e) { setverdict(pass); }
else { setverdict(fail, "Expected: ", rec2_e, ", got: ", rec2); }
if (roi == roi_e) { setverdict(pass); }
else { setverdict(fail, "Expected: ", roi_e, ", got: ", roi); }
if (uni == c_unis[8]) { setverdict(pass); }
else { setverdict(fail, "Expected: ", c_unis[8], ", got: ", uni); }
if (arr == c_arr) { setverdict(pass); }
else { setverdict(fail, "Expected: ", c_arr, ", got: ", arr); }
}
testcase tc_func_subref_convert() runs on CT
{
var integer int_res := hex2int(f_uni(c_unis[4]).hs) + oct2int(f_arr(c_arr)[3]);
var integer int_res_e := hex2int(c_unis[4].hs) + oct2int(c_arr[3]);
var Arr arr_res := { int2oct(f_roi(c_roi)[3], 2), str2oct(f_rec(c_rec).str),
char2oct(f_uni(c_unis[6]).cs), unichar2oct(f_uni(c_unis[7]).ucs, "UTF-8") };
var Arr arr_res_e := { int2oct(c_roi[3], 2), str2oct(c_rec.str),
char2oct(c_unis[6].cs), unichar2oct(c_unis[7].ucs, "UTF-8") };
if (int_res == int_res_e) { setverdict(pass); }
else { setverdict(fail, "Expected: ", int_res_e, ", got: ", int_res); }
if (arr_res == arr_res_e) { setverdict(pass); }
else { setverdict(fail, "Expected: ", arr_res_e, ", got: ", arr_res); }
}
testcase tc_func_subref_parameter() runs on CT
{
f_test(f_rec(c_rec).str, f_roi(c_roi)[0], f_uni(c_unis[2]).b, f_arr(c_arr)[1]);
var Arr enc_arr := { ef_enc_int(f_rec(c_rec).num), ef_enc_int(f_roi(c_roi)[2]),
ef_enc_oct(f_uni(c_unis[5]).os), ef_enc_oct(f_arr(c_arr)[3]) };
var Arr enc_arr_e := { ef_enc_int(c_rec.num), ef_enc_int(c_roi[2]),
ef_enc_oct(c_unis[5].os), ef_enc_oct(c_arr[3]) };
if (enc_arr == enc_arr_e) { setverdict(pass); }
else { setverdict(fail, "Expected: ", enc_arr_e, ", got: ", enc_arr); }
}
testcase tc_func_subref_send() runs on CT
{
connect(mtc:pt, mtc:pt);
pt.send(f_rec(c_rec).num);
pt.send(f_roi(c_roi)[1]);
pt.send(f_uni(c_unis[0]).i);
pt.send(f_arr(c_arr)[2]);
var default def := activate(as_ct());
var integer bad_int;
var octetstring bad_os;
t.start(1.0);
alt {
[] pt.receive(c_rec.num) { setverdict(pass); }
[] pt.receive(integer:?) -> value bad_int
{ setverdict(fail, "Expected: ", c_rec.num, ", got: ", bad_int); }
}
alt {
[] pt.receive(c_roi[1]) { setverdict(pass); }
[] pt.receive(integer:?) -> value bad_int
{ setverdict(fail, "Expected: ", c_roi[1], ", got: ", bad_int); }
}
alt {
[] pt.receive(c_unis[0].i) { setverdict(pass); }
[] pt.receive(integer:?) -> value bad_int
{ setverdict(fail, "Expected: ", c_unis[0].i, ", got: ", bad_int); }
}
alt {
[] pt.receive(c_arr[2]) { setverdict(pass); }
[] pt.receive(octetstring:?) -> value bad_os
{ setverdict(fail, "Expected: ", c_arr[2], ", got: ", bad_os); }
}
deactivate(def);
}
testcase tc_func_subref_complex() runs on CT
{
var Complex x := { rec := c_rec, roi := c_roi, unis := c_unis };
var RoI roi_res := { f_complex(x).rec.num, 3 * f_complex(x).roi[2],
float2int(f_complex(x).unis[1].f) - lengthof(f_complex(x).roi) };
var RoI roi_res_e := { x.rec.num, 3 * x.roi[2],
float2int(x.unis[1].f) - lengthof(x.roi) };
if (roi_res == roi_res_e) { setverdict(pass); }
else { setverdict(fail, "Expected: ", roi_res_e, ", got: ", roi_res); }
if (f_complex(x).unis[9].size == x.unis[9].size) { setverdict(pass); }
else { setverdict(fail, "Expected: ", x.unis[9].size, ", got: ", f_complex(x).unis[9].size); }
if (isbound(f_complex(x).rec)) { setverdict(pass); }
else { setverdict(fail, "Expected bound record field"); }
}
testcase tc_func_subref_ttcn2string() runs on CT
{
var charstring str1 := ttcn2string(f_rec(c_rec).str);
var charstring str1_e := ttcn2string(c_rec.str);
var charstring str2 := ttcn2string(f_roi(c_roi)[1]);
var charstring str2_e := ttcn2string(c_roi[1]);
var charstring str3 := ttcn2string(f_uni(c_unis[7]).ucs);
var charstring str3_e := ttcn2string(c_unis[7].ucs);
var charstring str4 := ttcn2string(f_arr(c_arr)[2]);
var charstring str4_e := ttcn2string(c_arr[2]);
if (str1 == str1_e) { setverdict(pass); }
else { setverdict(fail, "Expected: ", str1_e, ", got: ", str1); }
if (str2 == str2_e) { setverdict(pass); }
else { setverdict(fail, "Expected: ", str2_e, ", got: ", str2); }
if (str3 == str3_e) { setverdict(pass); }
else { setverdict(fail, "Expected: ", str3_e, ", got: ", str3); }
if (str4 == str4_e) { setverdict(pass); }
else { setverdict(fail, "Expected: ", str4_e, ", got: ", str4); }
}
testcase tc_func_subref_temp_var_assign() runs on CT
{
var template charstring vt1 := f_rec_temp(t_rec).str;
var template integer vt2 := f_roi_temp(t_roi)[0];
var template verdicttype vt3 := f_uni_temp(t_unis[8]).vt;
var template octetstring vt4 := f_arr_temp(t_arr)[3];
if (log2str(vt1) == log2str(t_rec.str)) { setverdict(pass); }
else { setverdict(fail, "Expected: ", t_rec.str, ", got: ", vt1); }
if (log2str(vt2) == log2str(t_roi[0])) { setverdict(pass); }
else { setverdict(fail, "Expected: ", t_roi[0], ", got: ", vt2); }
if (log2str(vt3) == log2str(t_unis[8].vt)) { setverdict(pass); }
else { setverdict(fail, "Expected: ", t_unis[8].vt, ", got: ", vt3); }
if (log2str(vt4) == log2str(t_arr[3])) { setverdict(pass); }
else { setverdict(fail, "Expected: ", t_arr[3], ", got: ", vt4); }
}
testcase tc_func_subref_temp_match() runs on CT
{
var charstring v_good1 := "affx_Y1b";
var integer v_good2 := -19;
var float v_good3 := 0.6;
var octetstring v_good4 := '12EF'O;
var integer v_bad1 := 331;
var integer v_bad2 := -20;
var bitstring v_bad3 := '110111'B;
var octetstring v_bad4 := 'ABCDEF'O;
if (match(v_good1, f_rec_temp(t_rec).str)) { setverdict(pass); }
else { setverdict(fail, "Expected ", v_good1, " to match ", f_rec_temp(t_rec).str); }
if (match(v_good2, f_roi_temp(t_roi)[0])) { setverdict(pass); }
else { setverdict(fail, "Expected ", v_good2, " to match ", f_roi_temp(t_roi)[0]); }
if (match(v_good3, f_uni_temp(t_unis[1]).f)) { setverdict(pass); }
else { setverdict(fail, "Expected ", v_good3, " to match ", f_uni_temp(t_unis[1]).f); }
if (match(v_good4, f_arr_temp(t_arr)[0])) { setverdict(pass); }
else { setverdict(fail, "Expected ", v_good4, " to match ", f_arr_temp(t_arr)[0]); }
if (not match(v_bad1, f_rec_temp(t_rec).num)) { setverdict(pass); }
else { setverdict(fail, "Expected ", v_bad1, " not to match ", f_rec_temp(t_rec).num); }
if (not match(v_bad2, f_roi_temp(t_roi)[2])) { setverdict(pass); }
else { setverdict(fail, "Expected ", v_bad2, " not to match ", f_roi_temp(t_roi)[2]); }
if (not match(v_bad3, f_uni_temp(t_unis[3]).bs)) { setverdict(pass); }
else { setverdict(fail, "Expected ", v_bad3, " not to match ", f_uni_temp(t_unis[3]).bs); }
if (not match(v_bad4, f_arr_temp(t_arr)[3])) { setverdict(pass); }
else { setverdict(fail, "Expected ", v_bad4, " not to match ", f_arr_temp(t_arr)[3]); }
}
testcase tc_func_subref_temp_value() runs on CT
{
if (not isvalue(f_rec_temp(t_rec).num)) { setverdict(pass); }
else { setverdict(fail, "Expected ", f_rec_temp(t_rec).num, " to not be a value."); }
if (isvalue(f_roi_temp(t_roi)[1])) { setverdict(pass); }
else { setverdict(fail, "Expected ", f_roi_temp(t_roi)[1], " to be a value."); }
if (isvalue(f_uni_temp(t_unis[4]).hs)) { setverdict(pass); }
else { setverdict(fail, "Expected ", f_uni_temp(t_unis[4]).hs, " to be a value."); }
if (isvalue(f_arr_temp(t_arr)[2])) { setverdict(pass); }
else { setverdict(fail, "Expected ", f_arr_temp(t_arr)[2], " to be a value."); }
if (valueof(f_roi_temp(t_roi)[1]) == valueof(t_roi[1])) { setverdict(pass); }
else { setverdict(fail, "Expected: ", t_roi[1], ", got: ", f_roi_temp(t_roi)[1]); }
if (valueof(f_uni_temp(t_unis[7]).ucs) == valueof(t_unis[7].ucs)) { setverdict(pass); }
else { setverdict(fail, "Expected: ", t_unis[7].ucs, ", got: ", f_uni_temp(t_unis[7]).ucs); }
if (valueof(f_arr_temp(t_arr)[3]) == valueof(t_arr[3])) { setverdict(pass); }
else { setverdict(fail, "Expected: ", t_arr[3], ", got: ", f_arr_temp(t_arr)[3]); }
}
testcase tc_func_subref_temp_structure() runs on CT
{
var template Rec rec1 := { num := f_rec_temp(t_rec).num, str := f_rec_temp(t_rec).str }; // == t_rec
var template Rec rec2 := { f_roi_temp(t_roi)[1], f_uni_temp(t_unis[6]).cs };
var template Rec rec2_e := { t_roi[1], t_unis[6].cs };
var template RoI roi := { f_uni_temp(t_unis[0]).i, 91, f_roi_temp(t_roi)[2], (0..infinity) };
var template RoI roi_e := { t_unis[0].i, 91, t_roi[2], (0..infinity) };
var template Uni uni := { vt := f_uni_temp(t_unis[8]).vt }; // == t_unis[8]
var template Arr arr := { [3] := f_arr_temp(t_arr)[3], [2] := f_arr_temp(t_arr)[2],