blob: 40ea0bc5d9a0d1b3e727179bc518429e4428b18b [file] [log] [blame]
///////////////////////////////////////////////////////////////////////////////
// //
// 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 //
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
// Module: EPTF_SMacro_Test_Testcases
//
// Purpose:
// This module contains testcases for testing EPTF SMacro.
//
// Module Parameters:
// -
// Module depends on:
// <EPTF_SMacro_Test_Definitions>
// <EPTF_CLL_SMacro_Definitions>
// <EPTF_CLL_SMacro_Functions>
// <EPTF_SMacro_Test_Functions>
// <EPTF_CLL_Base_Functions>
//
// Current Owner:
// Balazs Barcsik (ebalbar)
//
// Last Review Date:
// -
//
// Detailed Comments:
// -
///////////////////////////////////////////////////////////
module EPTF_SMacro_Test_Testcases {
//=========================================================================
// Import Part
//=========================================================================
import from EPTF_SMacro_Test_Definitions all;
import from EPTF_CLL_SMacro_Definitions all;
import from EPTF_CLL_SMacro_Functions all;
import from EPTF_SMacro_Test_Functions all;
import from EPTF_CLL_Base_Functions all;
import from EPTF_CLL_Logging_Functions all;
//=========================================================================
// Testcases
//=========================================================================
///////////////////////////////////////////////////////////
// Testcase: tc_EPTF_SMacro_Test_init
//
// Purpose:
// to test f_EPTF_SMacro_init_CT() function
//
// Requirement:
// -
//
// Action:
// - calls f_EPTF_SMacro_init_CT() function
// - calls f_EPTF_Base_stop() function
//
// Expected Result:
// - pass
///////////////////////////////////////////////////////////
testcase tc_EPTF_SMacro_Test_init() runs on SMacro_Test_CT {
f_EPTF_Base_init_CT("SMacro_Test_init");
f_EPTF_SMacro_init_CT("SMacro_Test_init");
f_EPTF_Base_stop(pass);
}
///////////////////////////////////////////////////////////
// Testcase: tc_EPTF_SMacro_Test_invalidMacroName
//
// Purpose:
// to test f_EPTF_SMacro_define() function if the macro name is invalid
//
// Requirement:
// -
//
// Action:
// - calls f_EPTF_SMacro_init_CT() function
// - calls f_EPTF_SMacro_define() function with invalid macro name
// - checks the return value of f_EPTF_SMacro_define() and set the verdict accordingly
//
// Expected Result:
// - pass
///////////////////////////////////////////////////////////
testcase tc_EPTF_SMacro_Test_invalidMacroName() runs on SMacro_Test_CT {
f_EPTF_SMacro_init_CT("SMacro_Test_invalidMacroName");
var charstring vl_macro_name := "macro$name";
var charstring vl_macro_value := "macro_value";
// invalid name "macro$name"
if(f_EPTF_SMacro_define(vl_macro_name, vl_macro_value) == 0) {
setverdict(fail,"Macro is defined in spite of the name is invalid: ", vl_macro_name);
f_EPTF_Base_stop(none);
}
//action("Macro define function returned an error code correctly because the macro name is invalid");
//.... other invalid names
// invalid name "macro name"
vl_macro_name := "macro name";
if(f_EPTF_SMacro_define(vl_macro_name, vl_macro_value) == 0) {
setverdict(fail,"Macro is defined in spite of the name is invalid: ", vl_macro_name);
f_EPTF_Base_stop(none);
}
// invalid name "\nmacroname"
vl_macro_name := "\nmacroname";
if(f_EPTF_SMacro_define(vl_macro_name, vl_macro_value) == 0) {
setverdict(fail,"Macro is defined in spite of the name is invalid: ", vl_macro_name);
f_EPTF_Base_stop(none);
}
// invalid name "macro\nname"
vl_macro_name := "macro\nname";
if(f_EPTF_SMacro_define(vl_macro_name, vl_macro_value) == 0) {
setverdict(fail,"Macro is defined in spite of the name is invalid: ", vl_macro_name);
f_EPTF_Base_stop(none);
}
// invalid name "\tmacroname"
vl_macro_name := "\tmacroname";
if(f_EPTF_SMacro_define(vl_macro_name, vl_macro_value) == 0) {
setverdict(fail,"Macro is defined in spite of the name is invalid: ", vl_macro_name);
f_EPTF_Base_stop(none);
}
// invalid name "macro\tname"
vl_macro_name := "macro\tname";
if(f_EPTF_SMacro_define(vl_macro_name, vl_macro_value) == 0) {
setverdict(fail,"Macro is defined in spite of the name is invalid: ", vl_macro_name);
f_EPTF_Base_stop(none);
}
//missing name: "("
vl_macro_name := "(";
if(f_EPTF_SMacro_define(vl_macro_name, vl_macro_value) == 0) {
setverdict(fail,"Macro is defined in spite of the name is invalid: ", vl_macro_name);
f_EPTF_Base_stop(none);
}
//missing name: ")"
vl_macro_name := ")";
if(f_EPTF_SMacro_define(vl_macro_name, vl_macro_value) == 0) {
setverdict(fail,"Macro is defined in spite of the name is invalid: ", vl_macro_name);
f_EPTF_Base_stop(none);
}
//missing name: "%abc"
vl_macro_name := "%abc";
if(f_EPTF_SMacro_define(vl_macro_name, vl_macro_value) == 0) {
setverdict(fail,"Macro is defined in spite of the name is invalid: ", vl_macro_name);
f_EPTF_Base_stop(none);
}
//missing name: "-"
vl_macro_name := "-";
if(f_EPTF_SMacro_define(vl_macro_name, vl_macro_value) == 0) {
setverdict(fail,"Macro is defined in spite of the name is invalid: ", vl_macro_name);
f_EPTF_Base_stop(none);
}
f_EPTF_Base_stop(pass);
}
///////////////////////////////////////////////////////////
// Testcase: tc_EPTF_SMacro_Test_invalidMacroNameWithLoggingInitialized
//
// Purpose:
// to test if the warning log works when logging is initialized (artf462341)
//
// Requirement:
// -
//
// Action:
// - calls f_EPTF_SMacro_init_CT() function
// - calls f_EPTF_Logging_init_CT() function
// - calls f_EPTF_SMacro_define() function with invalid macro name
// - checks the return value of f_EPTF_SMacro_define() and set the verdict accordingly
//
// Expected Result:
// - pass
///////////////////////////////////////////////////////////
testcase tc_EPTF_SMacro_Test_invalidMacroNameWithLoggingInitialized() runs on SMacro_Test_InvalidMacroNameWithLoggingInitialized_CT {
f_EPTF_SMacro_init_CT("SMacro_Test_invalidMacroNameWithLoggingInitialized");
f_EPTF_Logging_init_CT("SMacro_Test_invalidMacroNameWithLoggingInitialized");
// to check the warning message:
f_EPTF_Logging_registerPreambleFn(pl_f_EPTF_Logging_preamble:=refers(f_EPTF_SMacro_Test_invalidMacroNameWithLoggingInitialized_preamble_FT));
v_warningLogged := false;
var charstring vl_macro_name := "macro$name";
var charstring vl_macro_value := "macro_value";
// invalid name "macro$name"
if(f_EPTF_SMacro_define(vl_macro_name, vl_macro_value) == 0) {
setverdict(fail,"Macro is defined in spite of the name is invalid: ", vl_macro_name);
f_EPTF_Base_stop(none);
}
//action("Macro define function returned an error code correctly because the macro name is invalid");
if (not v_warningLogged) {
setverdict(fail, "Expected warning message was not logged.")
}
f_EPTF_Base_stop(pass);
}
///////////////////////////////////////////////////////////
// Testcase: tc_EPTF_SMacro_Test_reDefineMacro
//
// Purpose:
// to test f_EPTF_SMacro_define() function if macro is redefined
//
// Requirement:
// -
//
// Action:
// - calls f_EPTF_SMacro_init_CT() function
// - calls f_EPTF_SMacro_define() function twice
// - checks the return value of f_EPTF_SMacro_resolve() and set the verdict accordingly
//
// Expected Result:
// - pass
///////////////////////////////////////////////////////////
testcase tc_EPTF_SMacro_Test_reDefineMacro() runs on SMacro_Test_CT {
f_EPTF_SMacro_init_CT("SMacro_Test_reDefineMacro");
var charstring vl_macro_name := "macro_name";
var charstring vl_macro_value1 := "macro_value1";
var charstring vl_macro_value2 := "macro_value2";
if(f_EPTF_SMacro_define(vl_macro_name, vl_macro_value1) != 0) {
setverdict(fail, "Macro cannot be defined, but macro is correct");
f_EPTF_Base_stop(none);
}
var charstring vl_resolved_value := f_EPTF_SMacro_resolve("$"&vl_macro_name);
if(vl_resolved_value != vl_macro_value1) {
setverdict(fail,"Resolved value is wrong after it was defined: ", vl_resolved_value, ". It should be: ", vl_macro_value1);
f_EPTF_Base_stop(none);
}
if(f_EPTF_SMacro_define(vl_macro_name,vl_macro_value2) != 0) {
setverdict(fail, "Macro cannot be re-defined, but macro is correct");
f_EPTF_Base_stop(none);
}
vl_resolved_value := f_EPTF_SMacro_resolve("$"&vl_macro_name);
if(vl_resolved_value != vl_macro_value2) {
setverdict(fail,"Macro value is wrong after it was redefined: ", vl_resolved_value, ". It should be: ", vl_macro_value2);
f_EPTF_Base_stop(none);
}
setverdict(pass,"Macro is successfully redefined");
f_EPTF_Base_stop(pass);
}
///////////////////////////////////////////////////////////
// Testcase: tc_EPTF_SMacro_Test_unDefineMacro
//
// Purpose:
// to test f_EPTF_SMacro_undefine() function
//
// Requirement:
// -
//
// Action:
// - calls f_EPTF_SMacro_init_CT() function
// - calls f_EPTF_SMacro_define() function
// - calls f_EPTF_SMacro_undefine() function
// - calls f_EPTF_SMacro_resolve function
// - calls f_EPTF_SMacro_define() function
// - calls f_EPTF_SMacro_resolve function
//
// Expected Result:
// - pass
///////////////////////////////////////////////////////////
testcase tc_EPTF_SMacro_Test_unDefineMacro() runs on SMacro_Test_CT {
f_EPTF_SMacro_init_CT("SMacro_Test_unDefineMacro");
var charstring vl_macro_name := "macro_name";
var charstring vl_macro_value1 := "macro_value1";
var charstring vl_macro_value2 := "macro_value2";
if(f_EPTF_SMacro_define(vl_macro_name, vl_macro_value1) != 0) {
setverdict(fail, "Macro cannot be defined");
f_EPTF_Base_stop(none);
}
f_EPTF_SMacro_undefine(vl_macro_name);
var charstring vl_string_template := "$"&vl_macro_name;
var charstring vl_resolved_value := f_EPTF_SMacro_resolve(vl_string_template);
if(vl_resolved_value != vl_string_template) {
setverdict(fail, "Macro value is wrong after it was undefined: ", vl_resolved_value, ". It should be: ", vl_string_template);
f_EPTF_Base_stop(none);
}
if(f_EPTF_SMacro_define(vl_macro_name,vl_macro_value2) != 0) {
setverdict(fail, "Macro cannot be defined with a new value after undefine");
f_EPTF_Base_stop(none);
}
vl_resolved_value := f_EPTF_SMacro_resolve(vl_string_template);
if(vl_resolved_value != vl_macro_value2) {
setverdict(fail, "Macro value is wrong after it was defined again: ", vl_resolved_value, ". It should be: ", vl_macro_value2);
f_EPTF_Base_stop(none);
}
f_EPTF_Base_stop(pass);
}
///////////////////////////////////////////////////////////
// Testcase: tc_EPTF_SMacro_Test_unDefineUnknownMacro
//
// Purpose:
// to test f_EPTF_SMacro_undefine() function with not defined macro
//
// Requirement:
// -
//
// Action:
// - calls f_EPTF_SMacro_init_CT() function
// - calls f_EPTF_SMacro_define() function
// - calls f_EPTF_SMacro_resolve() function
// - calls f_EPTF_SMacro_undefine() function
// - calls f_EPTF_SMacro_undefine() function
// - calls f_EPTF_SMacro_resolve() function
//
// Expected Result:
// - pass
///////////////////////////////////////////////////////////
testcase tc_EPTF_SMacro_Test_unDefineUnknownMacro() runs on SMacro_Test_CT {
f_EPTF_SMacro_init_CT("SMacro_Test_unDefineUnknownMacro");
var charstring vl_macro_name := "macro_name";
var charstring vl_macro_value := "macro_value";
if(f_EPTF_SMacro_define(vl_macro_name, vl_macro_value) != 0) {
setverdict(fail, "Macro cannot be defined");
f_EPTF_Base_stop(none);
}
var charstring vl_string_template := "$"&vl_macro_name;
var charstring vl_resolved_value := f_EPTF_SMacro_resolve(vl_string_template);
var charstring vl_expected_value := vl_macro_value;
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong after it was defined: ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
f_EPTF_SMacro_undefine(vl_macro_name);
// macro is unknown
f_EPTF_SMacro_undefine(vl_macro_name);
vl_resolved_value := f_EPTF_SMacro_resolve(vl_string_template);
vl_expected_value := vl_string_template;
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong after it was undefined: ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
f_EPTF_Base_stop(pass);
}
///////////////////////////////////////////////////////////
// Testcase: tc_EPTF_SMacro_Test_registerCalcFn_defaultFnName
//
// Purpose:
// to test f_EPTF_SMacro_registerCalcFn function with default function name
//
// Requirement:
// -
//
// Action:
// - calls f_EPTF_SMacro_init_CT() function
// - calls f_EPTF_SMacro_define() function
// - calls f_EPTF_SMacro_registerCalcFn() function
// - calls f_EPTF_SMacro_resolve() function
// - calls f_EPTF_SMacro_deregisterCalcFn() function
// - calls f_EPTF_SMacro_resolve() function
//
// Expected Result:
// - pass
///////////////////////////////////////////////////////////
testcase tc_EPTF_SMacro_Test_registerCalcFn_defaultFnName() runs on SMacro_Test_CT {
f_EPTF_SMacro_init_CT("SMacro_Test_registerCalcFn_defaultFnName");
var charstring vl_macro_name := "macro_name";
var charstring vl_macro_value := "EPTF_SMacro_Test_Functions.f_EPTF_SMacro_Test_macro_concatPars";
var charstring vl_macro_par1 := "par1";
if(f_EPTF_SMacro_define(vl_macro_name, vl_macro_value) != 0) {
setverdict(fail, "Macro cannot be defined");
f_EPTF_Base_stop(none);
}
// registration with default function name
f_EPTF_SMacro_registerCalcFn(
pl_macro_function := refers(f_EPTF_SMacro_Test_macro_concatPars)
);
var charstring vl_string_template := "$("&vl_macro_name&" , "&log2str(vl_macro_par1)&" )";
var charstring vl_resolved_value := f_EPTF_SMacro_resolve(vl_string_template);
var charstring vl_expected_value := "macro_concatPars_Value=-"&vl_macro_par1&"-$macro_name4-";
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong after it was defined: ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
f_EPTF_SMacro_deregisterCalcFn(
pl_functionName := vl_macro_value
);
vl_string_template := "$("&vl_macro_name&" , "&log2str(vl_macro_par1)&" )";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_string_template);
vl_expected_value := vl_macro_value;
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong after it was defined: ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
f_EPTF_Base_stop(pass);
}
///////////////////////////////////////////////////////////
// Testcase: tc_EPTF_SMacro_Test_registerCalcFn_existingFnName
//
// Purpose:
// to test f_EPTF_SMacro_registerCalcFn function with existing function name
//
// Requirement:
// -
//
// Action:
// - calls f_EPTF_SMacro_init_CT() function
// - calls f_EPTF_SMacro_define() function
// - calls f_EPTF_SMacro_registerCalcFn() function
// - calls f_EPTF_SMacro_resolve() function
// - calls f_EPTF_SMacro_deregisterCalcFn() function
// - calls f_EPTF_SMacro_resolve() function
//
// Expected Result:
// - pass
///////////////////////////////////////////////////////////
testcase tc_EPTF_SMacro_Test_registerCalcFn_existingFnName() runs on SMacro_Test_CT {
f_EPTF_SMacro_init_CT("SMacro_Test_registerCalcFn_existingFnName");
var charstring vl_macro_name := "macro_name";
var charstring vl_macro_value := "macro_value";
var charstring vl_macro_par1 := "par1";
if(f_EPTF_SMacro_define(vl_macro_name, vl_macro_value) != 0) {
setverdict(fail, "Macro cannot be defined");
f_EPTF_Base_stop(none);
}
f_EPTF_SMacro_registerCalcFn(
pl_functionName := vl_macro_value,
pl_macro_function := refers(f_EPTF_SMacro_Test_macro_concatPars)
);
var charstring vl_string_template := "$("&vl_macro_name&" , "&log2str(vl_macro_par1)&" )";
var charstring vl_resolved_value := f_EPTF_SMacro_resolve(vl_string_template);
var charstring vl_expected_value := "macro_concatPars_Value=-"&vl_macro_par1&"-$macro_name4-";
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong after it was defined: ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
f_EPTF_SMacro_registerCalcFn(
pl_functionName := vl_macro_value,
pl_macro_function := refers(f_EPTF_SMacro_Test_macro_concatPars),
pl_userArgs :={1,0} // no concatMacro
);
vl_string_template := "$("&vl_macro_name&" , "&log2str(vl_macro_par1)&" )";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_string_template);
vl_expected_value := "macro_concatPars_Value=-"&vl_macro_par1&"--";
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong after it was defined: ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
f_EPTF_SMacro_registerCalcFn(
pl_functionName := vl_macro_value,
pl_macro_function := refers(f_EPTF_SMacro_Test_macro_concatPars),
pl_userArgs :={0,0} // no concatChar & no concatMacro
);
vl_string_template := "$("&vl_macro_name&" , "&log2str(vl_macro_par1)&" )";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_string_template);
vl_expected_value := "macro_concatPars_Value="&vl_macro_par1&"";
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong after it was defined: ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
f_EPTF_SMacro_registerCalcFn(
pl_functionName := vl_macro_value,
pl_macro_function := null // null function ref
)
vl_string_template := "$("&vl_macro_name&" , "&log2str(vl_macro_par1)&" )";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_string_template);
vl_expected_value := ""&vl_macro_value&"";
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong after it was defined: ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
f_EPTF_Base_stop(pass);
}
///////////////////////////////////////////////////////////
// Testcase: tc_EPTF_SMacro_Test_deregisterCalcFn
//
// Purpose:
// to test f_EPTF_SMacro_deregisterCalcFn function
//
// Requirement:
// -
//
// Action:
// - calls f_EPTF_SMacro_init_CT() function
// - calls f_EPTF_SMacro_define() function
// - calls f_EPTF_SMacro_registerCalcFn() function
// - calls f_EPTF_SMacro_resolve() function
// - calls f_EPTF_SMacro_deregisterCalcFn() function
// - calls f_EPTF_SMacro_resolve() function
//
// Expected Result:
// - pass
///////////////////////////////////////////////////////////
testcase tc_EPTF_SMacro_Test_deregisterCalcFn() runs on SMacro_Test_CT {
f_EPTF_SMacro_init_CT("SMacro_Test_deregisterCalcFn");
var charstring vl_macro_name := "macro_name";
var charstring vl_macro_value := "macro_value";
var charstring vl_macro_par1 := "par1";
if(f_EPTF_SMacro_define(vl_macro_name, vl_macro_value) != 0) {
setverdict(fail, "Macro cannot be defined");
f_EPTF_Base_stop(none);
}
f_EPTF_SMacro_registerCalcFn(
pl_functionName := vl_macro_value,
pl_macro_function := refers(f_EPTF_SMacro_Test_macro_concatPars)
);
var charstring vl_string_template := "$("&vl_macro_name&" , "&log2str(vl_macro_par1)&" )";
var charstring vl_resolved_value := f_EPTF_SMacro_resolve(vl_string_template);
var charstring vl_expected_value := "macro_concatPars_Value=-"&vl_macro_par1&"-$macro_name4-";
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong after it was defined: ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
f_EPTF_SMacro_deregisterCalcFn(
pl_functionName := vl_macro_value
);
vl_string_template := "$("&vl_macro_name&" , "&log2str(vl_macro_par1)&" )";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_string_template);
vl_expected_value := vl_macro_value;
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong after it was defined: ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
f_EPTF_Base_stop(pass);
}
///////////////////////////////////////////////////////////
// Testcase: tc_EPTF_SMacro_Test_deregisterUnknownCalcFn
//
// Purpose:
// to test f_EPTF_SMacro_deregisterCalcFn function with not registered calc function
//
// Requirement:
// -
//
// Action:
// - calls f_EPTF_SMacro_init_CT() function
// - calls f_EPTF_SMacro_define() function
// - calls f_EPTF_SMacro_registerCalcFn() function
// - calls f_EPTF_SMacro_resolve() function
// - calls f_EPTF_SMacro_deregisterCalcFn() function
// - calls f_EPTF_SMacro_deregisterCalcFn() function
// - calls f_EPTF_SMacro_resolve() function
//
// Expected Result:
// - pass
///////////////////////////////////////////////////////////
testcase tc_EPTF_SMacro_Test_deregisterUnknownCalcFn() runs on SMacro_Test_CT {
f_EPTF_SMacro_init_CT("SMacro_Test_deregisterUnknownCalcFn");
var charstring vl_macro_name := "macro_name";
var charstring vl_macro_value := "macro_value";
var charstring vl_macro_par1 := "par1";
if(f_EPTF_SMacro_define(vl_macro_name, vl_macro_value) != 0) {
setverdict(fail, "Macro cannot be defined");
f_EPTF_Base_stop(none);
}
f_EPTF_SMacro_registerCalcFn(
pl_functionName := vl_macro_value,
pl_macro_function := refers(f_EPTF_SMacro_Test_macro_concatPars)
);
var charstring vl_string_template := "$("&vl_macro_name&" , "&log2str(vl_macro_par1)&" )";
var charstring vl_resolved_value := f_EPTF_SMacro_resolve(vl_string_template);
var charstring vl_expected_value := "macro_concatPars_Value=-"&vl_macro_par1&"-$macro_name4-";
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong after it was defined: ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
f_EPTF_SMacro_deregisterCalcFn(
pl_functionName := vl_macro_value
);
// calc function is unknown
f_EPTF_SMacro_deregisterCalcFn(
pl_functionName := vl_macro_value
);
vl_string_template := "$("&vl_macro_name&" , "&log2str(vl_macro_par1)&" )";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_string_template);
vl_expected_value := vl_macro_value;
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong after it was defined: ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
f_EPTF_Base_stop(pass);
}
///////////////////////////////////////////////////////////
// Testcase: tc_EPTF_SMacro_Test_resolveMacro
//
// Purpose:
// to test f_EPTF_SMacro_resolve() function
//
// Requirement:
// -
//
// Action:
// - calls f_EPTF_SMacro_init_CT() function
// - calls f_EPTF_SMacro_define() function
// - checks the return value of f_EPTF_SMacro_resolve() and set the verdict accordingly
//
// Expected Result:
// - pass
///////////////////////////////////////////////////////////
testcase tc_EPTF_SMacro_Test_resolveMacro() runs on SMacro_Test_CT {
f_EPTF_SMacro_Test_init_CT("SMacro_Test_resolveMacro");
var charstring vl_macro_par1 := " par1 ";
var charstring vl_macro_par2 := " par2 ";
var charstring vl_macro_par_macro := " $macro_name2 ";
var charstring vl_macro_par3 := " $( par3 ";
var charstring vl_macro_par4 := " pa$( )r4 ";
var charstring vl_macro_par5 := " par5 ) ";
var charstring vl_macro_par6 := " $( par6 ) ";
var charstring vl_macro_par7 := " $(macro";
var charstring vl_macro_par8 := "_name4) ";
// check syntax: "$MACRO_NAME"
var charstring vl_resolved_value := f_EPTF_SMacro_resolve("$"&v_macro_name1);
if(vl_resolved_value != v_macro_value1) {
setverdict(fail,"Resolved value is wrong after it was defined: ", vl_resolved_value, ". It should be: ", v_macro_value1);
f_EPTF_Base_stop(none);
}
// check syntax: "$(MACRO_NAME)"
vl_resolved_value := f_EPTF_SMacro_resolve("$("&v_macro_name1&")");
if(vl_resolved_value != v_macro_value1) {
setverdict(fail,"Resolved value is wrong after it was defined: ", vl_resolved_value, ". It should be: ", v_macro_value1);
f_EPTF_Base_stop(none);
}
// check syntax: "$(MACRO_NAME , \" par1 \", \" par2 \" )"
vl_resolved_value := f_EPTF_SMacro_resolve("$("&v_macro_name3&" , "&log2str(vl_macro_par1)&" , "&log2str(vl_macro_par2)&" )");
var charstring vl_expected_value := "macro_concatPars_Value=-"&vl_macro_par1&"-"&vl_macro_par2&"-"&v_macro_value1&"-";
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong after it was defined: ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
// check syntax: "$(MACRO_NAME , \" par1 \", \" $MACRO2 \" )"
vl_resolved_value := f_EPTF_SMacro_resolve("$("&v_macro_name3&" , "&log2str(vl_macro_par1)&" , "&log2str(vl_macro_par_macro)&" )");
vl_expected_value := "macro_concatPars_Value=-"&vl_macro_par1&"- "&v_macro_value2&" -"&v_macro_value1&"-";
if(vl_resolved_value != vl_expected_value) { //^ ^ these spaces come from the macro parameter vl_macro_par_macro
setverdict(fail,"Resolved value is wrong after it was defined: ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
// check syntax: "abc_$MACRO_NAME-def"
vl_resolved_value := f_EPTF_SMacro_resolve("abc_$"&v_macro_name1&"-def");
if(vl_resolved_value != "abc_"&v_macro_value1&"-def") {
setverdict(fail,"Resolved value is wrong after it was defined: ", vl_resolved_value, ". It should be: ", "abc_"&v_macro_value1&"-def");
f_EPTF_Base_stop(none);
}
// check macro in value:
vl_resolved_value := f_EPTF_SMacro_resolve("$("&v_macro_name4&")");
if(vl_resolved_value != v_macro_value1) {
setverdict(fail,"Resolved value is wrong after it was defined: ", vl_resolved_value, ". It should be: ", v_macro_value1);
f_EPTF_Base_stop(none);
}
// check macro in value and par:
vl_resolved_value := f_EPTF_SMacro_resolve("$("&v_macro_name3&" , "&log2str(vl_macro_par1)&" , "&log2str("$"&v_macro_name4)&" )");
vl_expected_value := "macro_concatPars_Value=-"&vl_macro_par1&"-"&v_macro_value1&"-"&v_macro_value1&"-";
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong after it was defined: ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
//check if macro value is a macro name: "$$MACRO_NAME $($MACRO_NAME) $($MACRO_NAME,\"par1\") $($(MACRO_NAME,\"par1\"),\"par1\")"
vl_resolved_value := f_EPTF_SMacro_resolve("$$"&v_macro_name6&" $($"&v_macro_name6&") $($"&v_macro_name6&",\"par1\") $($("&v_macro_name6&",\"par1\"),\"par1\")");
vl_expected_value := v_macro_value1&" "&v_macro_value1&" "&v_macro_value1&" "&v_macro_value1;
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong after it was defined: ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
// check macro which has special characters in parameter, see in definition of vl_macro_par3...6
vl_resolved_value := f_EPTF_SMacro_resolve("$("&v_macro_name3&" , "&log2str(vl_macro_par3)&" , "&log2str(vl_macro_par4)&" , "&log2str(vl_macro_par5)&" , "&log2str(vl_macro_par6)&" )");
vl_expected_value := "macro_concatPars_Value=-"&vl_macro_par3&"-"&vl_macro_par4&"-"&vl_macro_par5&"-"&vl_macro_par6&"-"&v_macro_value1&"-";
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong after it was defined: ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
// check macro which is derived from the parameters: " vl_macro_par7&vl_macro_par8 " --> " $(macro4) " --> " $macro_name1 " --> " macro_name1 " --> " macro_value1 "
vl_resolved_value := f_EPTF_SMacro_resolve("$("&v_macro_name5&" , "&log2str(vl_macro_par7)&" , "&log2str(vl_macro_par8)&" )");
vl_expected_value := "macro_concatPars_Value="&" "&v_macro_value1&" "&"";
if(vl_resolved_value != vl_expected_value) { //^ ^ these spaces cames from the parameters
setverdict(fail,"Resolved value is wrong after it was defined: ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
// check syntax: "$(MACRO_NAME , \" par\\1 \", \" par\\2 \" )"
var charstring vl_macro_parBS1 := " par\t\\1 ";
var charstring vl_macro_parBS2 := " par\t\\2 ";
// template string : $(macro_name3, " par\t\\1 ", " par\t\\2 ")
// template string as charstring : "$(macro_name3, \" par\\t\\\\1 \", \" par\\t\\\\2 \")"
var charstring vl_templateString := "$("&v_macro_name3&" , "&log2str(vl_macro_parBS1)&" , "&log2str(vl_macro_parBS2)&" )";
// var charstring vl_templateString2 := "$("&v_macro_name3&" , "&log2str(vl_macro_parBS1," , ",vl_macro_parBS2)&" )";
action("*-----------------------------------------------------------------------------------------");
vl_resolved_value := f_EPTF_SMacro_resolve(vl_templateString);
vl_expected_value := "macro_concatPars_Value=-"&vl_macro_parBS1&"-"&vl_macro_parBS2&"-"&v_macro_value1&"-";
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong after it was defined: ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
action("*-----------------------------------------------------------------------------------------");
// check macro with parameter in par:
var charstring vl_macro_par_macro_with_par := "$("&v_macro_name3&" , "&log2str(vl_macro_par1)&" , "&log2str("$"&v_macro_name4)&" )";
vl_resolved_value := f_EPTF_SMacro_resolve("$("&v_macro_name3&" , "&log2str(vl_macro_par1)&" , "&log2str(vl_macro_par_macro_with_par)&" )" );
vl_expected_value := "macro_concatPars_Value=-"&vl_macro_par1&"-macro_concatPars_Value=-"&vl_macro_par1&"-"&v_macro_value1&"-"&v_macro_value1&"-"&"-"&v_macro_value1&"-";
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong after it was defined: ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
action("*-----------------------------------------------------------------------------------------");
// check macro with parameter in par 3rd level:
var charstring vl_macro_par_macro_with_par_par := "$("&v_macro_name3&" , "&log2str(vl_macro_par1)&" , "&log2str(vl_macro_par_macro_with_par)&" )";
vl_resolved_value := f_EPTF_SMacro_resolve("$("&v_macro_name3&" , "&log2str(vl_macro_par1)&" , "&log2str(vl_macro_par_macro_with_par_par)&" )" );
vl_expected_value := "macro_concatPars_Value=-"&vl_macro_par1&"-"&"macro_concatPars_Value=-"&vl_macro_par1&"-macro_concatPars_Value=-"&vl_macro_par1&"-"&v_macro_value1&"-"&v_macro_value1&"-"&"-"&v_macro_value1&"-"&"-"&v_macro_value1&"-";
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong after it was defined: ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
// check macro with escape characters at the end of parameter string
vl_resolved_value := f_EPTF_SMacro_resolve("$("&v_macro_name3&" , "&log2str(vl_macro_par1&"\\")&" , "&log2str(vl_macro_par2&"\\\\")&" )" );
vl_expected_value := "macro_concatPars_Value=-"&vl_macro_par1&"\\"&"-"&vl_macro_par2&"\\\\"&"-"&v_macro_value1&"-";
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong after it was defined: ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
setverdict(pass,"Macros are successfully resolved");
f_EPTF_Base_stop(pass);
}
///////////////////////////////////////////////////////////
// Testcase: tc_EPTF_SMacro_Test_resolveMacro_checkWrongMacroSyntax
//
// Purpose:
// to test f_EPTF_SMacro_resolve() function with wrong syntax in template string
//
// Requirement:
// -
//
// Action:
// - calls f_EPTF_SMacro_init_CT() function
// - calls f_EPTF_SMacro_define() function
// - checks the return value of f_EPTF_SMacro_resolve() and set the verdict accordingly
//
// Expected Result:
// - pass
///////////////////////////////////////////////////////////
testcase tc_EPTF_SMacro_Test_resolveMacro_checkWrongMacroSyntax() runs on SMacro_Test_CT {
f_EPTF_SMacro_Test_init_CT("SMacro_Test_resolveMacro_checkWrongMacroSyntax");
// check syntax: missing name "$() $$- $) $(,\"par\") $%abc $- $$macroname-"
var charstring vl_templateString := "$() $$- $) $(,\"par\") $%abc $- $$macroname-";
var charstring vl_resolved_value := f_EPTF_SMacro_resolve(vl_templateString);
var charstring vl_expected_value := vl_templateString;
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong after it was defined: ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
// check syntax: missing par "$(MACRO_NAME , )"
vl_templateString := "$("&v_macro_name1&" , )";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_templateString);
vl_expected_value := vl_templateString;
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong after it was defined: ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
// check syntax: missing par "$(MACRO_NAME , ,)"
vl_templateString := "$("&v_macro_name1&" , , )";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_templateString);
vl_expected_value := vl_templateString;
if(vl_resolved_value !=vl_expected_value) {
setverdict(fail,"Resolved value is wrong after it was defined: ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
// check syntax: wrong syntax "$(macroname-) $(macroname,abc) $(macroname- $(macroname\"par\") $(- $(macroname,- $(macroname,\"par\"- $(macroname,\"par\",- $(macroname,\"par\",\"par2\"-"
vl_templateString := "$("&v_macro_name1&"-) $("&v_macro_name1&",abc) $("&v_macro_name1&"- $("&v_macro_name1&"\"par\") $(- $("&v_macro_name1&",- $("&v_macro_name1&",\"par\"- $("&v_macro_name1&",\"par\",- $("&v_macro_name1&",\"par\",\"par2\"-";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_templateString);
vl_expected_value := vl_templateString;
if(vl_resolved_value !=vl_expected_value) {
setverdict(fail,"Resolved value is wrong after it was defined: ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
// check syntax: wrong syntax, unexpected EOL in param 1st: "abcd $(macroname,\"abs"
vl_templateString := "abcd $("&v_macro_name1&",\"abs";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_templateString);
vl_expected_value := vl_templateString;
if(vl_resolved_value !=vl_expected_value) {
setverdict(fail,"Resolved value is wrong after it was defined: ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
// check syntax: wrong syntax, unexpected EOL in param 2nd: "abcd $(macroname,\"par\",\"abs"
vl_templateString := "abcd $("&v_macro_name1&",\"par\",\"abs";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_templateString);
vl_expected_value := vl_templateString;
if(vl_resolved_value !=vl_expected_value) {
setverdict(fail,"Resolved value is wrong after it was defined: ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
setverdict(pass,"Macros are successfully resolved");
f_EPTF_Base_stop(pass);
}
//--------------- MACROS -----------------------------------------------
////////////////////////////////////////////////////
// Built-in Macro Tests
///////////////////////////////////////////////////
///////////////////////////////////////////////////////////
// Testcase: tc_EPTF_SMacro_Test_builtInMacro_EVAL_SingleExpressions
//
// Purpose:
// to test EVAL built-in macro
//
// Requirement:
// -
//
// Action:
// - calls f_EPTF_SMacro_init_CT() function
// - calls f_EPTF_SMacro_define() function
// - checks the return value of f_EPTF_SMacro_resolve() when $EVAL is used
//
// Expected Result:
// - pass
///////////////////////////////////////////////////////////
testcase tc_EPTF_SMacro_Test_builtInMacro_EVAL_SingleExpressions() runs on SMacro_Test_CT {
f_EPTF_SMacro_init_CT("SMacro_Test_builtInMacro_EVAL");
var charstring vl_templateString;
var charstring vl_resolved_value;
var charstring vl_expected_value;
//// operator* ///////////////////////////////////////
// check syntax: "$(EVAL , \"1*1\" )"
vl_templateString := "$("&c_EPTF_SMacro_macroName_EVAL&" , \"1*1\" )";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_templateString);
vl_expected_value := "1";
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong for template string ",vl_templateString,": ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
// check syntax: "$(EVAL , \"2.0*0.5\" )"
vl_templateString := "$("&c_EPTF_SMacro_macroName_EVAL&" , \"2.0*0.5\" )";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_templateString);
vl_expected_value := float2str(1.0);
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong for template string ",vl_templateString,": ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
// check syntax: "$(EVAL , \"2*0.5\" )"
vl_templateString := "$("&c_EPTF_SMacro_macroName_EVAL&" , \"2*0.5\" )";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_templateString);
vl_expected_value := float2str(1.0);
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong for template string ",vl_templateString,": ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
// check syntax: "$(EVAL , \"0.5*2\" )"
vl_templateString := "$("&c_EPTF_SMacro_macroName_EVAL&" , \"0.5*2\" )";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_templateString);
vl_expected_value := float2str(1.0);
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong for template string ",vl_templateString,": ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
// check syntax: "$(EVAL , \"-0.5*-2\" )"
vl_templateString := "$("&c_EPTF_SMacro_macroName_EVAL&" , \"-0.5*-2\" )";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_templateString);
vl_expected_value := float2str(1.0);
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong for template string ",vl_templateString,": ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
// check syntax: "$(EVAL , \"-0.5*-2e+0\" )"
vl_templateString := "$("&c_EPTF_SMacro_macroName_EVAL&" , \"-0.5*-2e+0\" )";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_templateString);
vl_expected_value := float2str(1.0);
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong for template string ",vl_templateString,": ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
//// operator/ ///////////////////////////////////////
// check syntax: "$(EVAL , \"1/1\" )"
vl_templateString := "$("&c_EPTF_SMacro_macroName_EVAL&" , \"1/1\" )";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_templateString);
vl_expected_value := "1";
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong for template string ",vl_templateString,": ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
// check syntax: "$(EVAL , \"2.0/2.0\" )"
vl_templateString := "$("&c_EPTF_SMacro_macroName_EVAL&" , \"2.0/2.0\" )";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_templateString);
vl_expected_value := float2str(1.0);
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong for template string ",vl_templateString,": ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
// check syntax: "$(EVAL , \"2/2.0\" )"
vl_templateString := "$("&c_EPTF_SMacro_macroName_EVAL&" , \"2/2.0\" )";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_templateString);
vl_expected_value := float2str(1.0);
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong for template string ",vl_templateString,": ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
// check syntax: "$(EVAL , \"2.0/2\" )"
vl_templateString := "$("&c_EPTF_SMacro_macroName_EVAL&" , \"2.0/2\" )";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_templateString);
vl_expected_value := float2str(1.0);
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong for template string ",vl_templateString,": ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
// check syntax: "$(EVAL , \"-2.0/-2\" )"
vl_templateString := "$("&c_EPTF_SMacro_macroName_EVAL&" , \"-2.0/-2\" )";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_templateString);
vl_expected_value := float2str(1.0);
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong for template string ",vl_templateString,": ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
// check syntax: "$(EVAL , \"-2.0/-2e+0\" )"
vl_templateString := "$("&c_EPTF_SMacro_macroName_EVAL&" , \"-0.5*-2e+0\" )";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_templateString);
vl_expected_value := float2str(1.0);
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong for template string ",vl_templateString,": ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
//// operator% ///////////////////////////////////////
// check syntax: "$(EVAL , \"2%3\" )"
vl_templateString := "$("&c_EPTF_SMacro_macroName_EVAL&" , \"2%3\" )";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_templateString);
vl_expected_value := "2";
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong for template string ",vl_templateString,": ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
// check syntax: "$(EVAL , \"-2%-3\" )"
vl_templateString := "$("&c_EPTF_SMacro_macroName_EVAL&" , \"-2%-3\" )";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_templateString);
vl_expected_value := "-2";
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong for template string ",vl_templateString,": ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
//// operator+ ///////////////////////////////////////
// check syntax: "$(EVAL , \"1+1\" )"
vl_templateString := "$("&c_EPTF_SMacro_macroName_EVAL&" , \"1+1\" )";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_templateString);
vl_expected_value := "2";
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong for template string ",vl_templateString,": ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
// check syntax: "$(EVAL , \"2.0+0.5\" )"
vl_templateString := "$("&c_EPTF_SMacro_macroName_EVAL&" , \"2.0+0.5\" )";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_templateString);
vl_expected_value := float2str(2.5);
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong for template string ",vl_templateString,": ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
// check syntax: "$(EVAL , \"2+0.5\" )"
vl_templateString := "$("&c_EPTF_SMacro_macroName_EVAL&" , \"2+0.5\" )";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_templateString);
vl_expected_value := float2str(2.5);
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong for template string ",vl_templateString,": ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
// check syntax: "$(EVAL , \"0.5+2\" )"
vl_templateString := "$("&c_EPTF_SMacro_macroName_EVAL&" , \"0.5+2\" )";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_templateString);
vl_expected_value := float2str(2.5);
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong for template string ",vl_templateString,": ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
// check syntax: "$(EVAL , \"-0.5+-2\" )"
vl_templateString := "$("&c_EPTF_SMacro_macroName_EVAL&" , \"-0.5+-2\" )";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_templateString);
vl_expected_value := float2str(-2.5);
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong for template string ",vl_templateString,": ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
// check syntax: "$(EVAL , \"-0.5+-2e+0\" )"
vl_templateString := "$("&c_EPTF_SMacro_macroName_EVAL&" , \"-0.5+-2e+0\" )";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_templateString);
vl_expected_value := float2str(-2.5);
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong for template string ",vl_templateString,": ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
//// operator- ///////////////////////////////////////
// check syntax: "$(EVAL , \"2-1\" )"
vl_templateString := "$("&c_EPTF_SMacro_macroName_EVAL&" , \"2-1\" )";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_templateString);
vl_expected_value := "1";
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong for template string ",vl_templateString,": ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
// check syntax: "$(EVAL , \"2.0-0.5\" )"
vl_templateString := "$("&c_EPTF_SMacro_macroName_EVAL&" , \"2.0-0.5\" )";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_templateString);
vl_expected_value := float2str(1.5);
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong for template string ",vl_templateString,": ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
// check syntax: "$(EVAL , \"2-0.5\" )"
vl_templateString := "$("&c_EPTF_SMacro_macroName_EVAL&" , \"2-0.5\" )";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_templateString);
vl_expected_value := float2str(1.5);
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong for template string ",vl_templateString,": ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
// check syntax: "$(EVAL , \"0.5-2\" )"
vl_templateString := "$("&c_EPTF_SMacro_macroName_EVAL&" , \"0.5-2\" )";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_templateString);
vl_expected_value := float2str(-1.5);
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong for template string ",vl_templateString,": ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
// check syntax: "$(EVAL , \"-0.5--2\" )"
vl_templateString := "$("&c_EPTF_SMacro_macroName_EVAL&" , \"-0.5--2\" )";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_templateString);
vl_expected_value := float2str(1.5);
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong for template string ",vl_templateString,": ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
// check syntax: "$(EVAL , \"-0.5--2e+0\" )"
vl_templateString := "$("&c_EPTF_SMacro_macroName_EVAL&" , \"-0.5--2e+0\" )";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_templateString);
vl_expected_value := float2str(1.5);
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong for template string ",vl_templateString,": ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
/// other syntax:
// check syntax: "$(EVAL , \"2+4/2*3-1\" )"
vl_templateString := "$("&c_EPTF_SMacro_macroName_EVAL&" , \"2+4/2*3-1\" )";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_templateString);
vl_expected_value := "7";
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong for template string ",vl_templateString,": ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
// check syntax: "$(EVAL , \"abc1*1def\" )"
vl_templateString := "$("&c_EPTF_SMacro_macroName_EVAL&" , \"abc1*1def\" )";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_templateString);
vl_expected_value := "abc1def";
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong for template string ",vl_templateString,": ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
// check syntax: "$(EVAL , \"abc1*1def\", \"strict\" )"
vl_templateString := "$("&c_EPTF_SMacro_macroName_EVAL&" , \"abc1*1def\", \"strict\" )";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_templateString);
vl_expected_value := "abc1*1def";
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong for template string ",vl_templateString,": ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
// check syntax: "$(EVAL , \"1+2.0*3/4*2-6e1\" )"
vl_templateString := "$("&c_EPTF_SMacro_macroName_EVAL&" , \"1+2.0*3/4*2-6e1\" )";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_templateString);
vl_expected_value := float2str(-56.0);
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong for template string ",vl_templateString,": ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
// check syntax: "$(EVAL , \"2.0*(3.0+5.0)\" )"
vl_templateString := "$("&c_EPTF_SMacro_macroName_EVAL&" , \"2.0*(3.0+5.0)\" )";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_templateString);
vl_expected_value := float2str(16.0);
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong for template string ",vl_templateString,": ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
// check syntax: "$(EVAL , \"((2))+(3*5)\" )"
vl_templateString := "$("&c_EPTF_SMacro_macroName_EVAL&" , \"((2))+(3*5)\" )";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_templateString);
vl_expected_value := "17";
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong for template string ",vl_templateString,": ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
// check syntax: "$(EVAL , \"(1.0*(2.0))*3.0\" )"
vl_templateString := "$("&c_EPTF_SMacro_macroName_EVAL&" , \"(1.0*(2.0))*3.0\" )";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_templateString);
vl_expected_value := float2str(6.0);
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong for template string ",vl_templateString,": ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
// check syntax: "$(EVAL , \"1.0*(2.0)*3.0\" )"
vl_templateString := "$("&c_EPTF_SMacro_macroName_EVAL&" , \"1.0*(2.0)*3.0\" )";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_templateString);
vl_expected_value := float2str(6.0);
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong for template string ",vl_templateString,": ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
// check syntax: "$(EVAL , \"1.0*(2.0*(3.0))\" )"
vl_templateString := "$("&c_EPTF_SMacro_macroName_EVAL&" , \"1.0*(2.0*(3.0))\" )";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_templateString);
vl_expected_value := float2str(6.0);
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong for template string ",vl_templateString,": ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
// check syntax: "$(EVAL , \"(0.5)*(-2.0)*(1-2.0)*3/(4*(2-6e-1))\" )"
vl_templateString := "$("&c_EPTF_SMacro_macroName_EVAL&" , \"(0.5)*(-2.0)*(1-2.0)*3/(-4*(2-6e-1))\" )";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_templateString);
vl_expected_value := float2str(3.0/-5.6);
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong for template string ",vl_templateString,": ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
// check syntax: "$(EVAL , \"((2.0))*(3.0+5.0)\" )"
vl_templateString := "$("&c_EPTF_SMacro_macroName_EVAL&" , \"((2.0))*(3.0+5.0)\" )";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_templateString);
vl_expected_value := float2str(16.0);
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong for template string ",vl_templateString,": ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
action("*-----------------------------------------------------------------------------------------");
// check syntax: "$(EVAL , \"a1+1b a1+-1b a1+-+1b a+-1+1b a-+1+1b a--+-+1++-+-+1b a(+-1+1)b a(-+1+1)b a1*(+--+1)b\" )"
var charstring vl_expressionString := "a1+1b a1+-1b a1+-+1b a+-1+1b a-+1+1b a--+-+1++-+-+1b a(+-1+1)b a(-+1+1)b a1*(+--+1)b";
vl_templateString := "$("&c_EPTF_SMacro_macroName_EVAL&" , "&log2str(vl_expressionString)&" )";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_templateString);
vl_expected_value := "a2b a0b a0b a0b a0b a0b a0b a0b a1b";
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong for template string ",vl_templateString,": ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
action("*-----------------------------------------------------------------------------------------");
// check syntax: "$(EVAL , \"a1*1b a1*-1b a1*-+1b a+-1*1b a-+1*1b a-+-1*-+--1+--1b\" )"
vl_expressionString := "a1*1b a1*-1b a1*-+1b a+-1*1b a-+1*1b a-+-1*-+--1+--1b";
vl_templateString := "$("&c_EPTF_SMacro_macroName_EVAL&" , "&log2str(vl_expressionString)&" )";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_templateString);
vl_expected_value := "a1b a-1b a-1b a-1b a-1b a0b";
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong for template string ",vl_templateString,": ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
setverdict(pass,"Macros are successfully resolved");
f_EPTF_Base_stop(pass);
}
///////////////////////////////////////////////////////////
// Testcase: tc_EPTF_SMacro_Test_autoEVAL
//
// Purpose:
// to test the auto-EVAL functionality
//
// Requirement:
// -
//
// Action:
// - calls f_EPTF_SMacro_init_CT() function
// - calls f_EPTF_SMacro_define() function
// - checks the return value of f_EPTF_SMacro_resolve(pl_autoEVAL:=true) when $EVAL is used
//
// Expected Result:
// - pass
///////////////////////////////////////////////////////////
testcase tc_EPTF_SMacro_Test_autoEVAL() runs on SMacro_Test_CT {
f_EPTF_SMacro_Test_init_CT("SMacro_Test_autoEVAL");
var charstring vl_templateString;
var charstring vl_resolved_value;
var charstring vl_expected_value;
var charstring vl_macro_name := "macro_name";
var charstring vl_macro_value1 := "3";
var charstring vl_macro_name2 := "3";
var charstring vl_macro_value2 := "5";
if(f_EPTF_SMacro_define(vl_macro_name, vl_macro_value1) != 0) {
setverdict(fail, "Macro cannot be defined");
f_EPTF_Base_stop(none);
}
if(f_EPTF_SMacro_define(vl_macro_name2, vl_macro_value2) != 0) {
setverdict(fail, "Macro cannot be defined");
f_EPTF_Base_stop(none);
}
// check syntax: "abc $(macro_name) 2+$(macro_name)*(4-5)*(-2*0.5) def"
vl_templateString := "$("&c_EPTF_SMacro_macroName_EVAL&" , \"abc-$(macro_name) 2+$(macro_name)*(4-5)*(-2*0.5) def\" )";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_templateString,pl_autoEVAL:=true);
vl_expected_value := "abc-3 "&float2str(5.0)&" def";
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong for template string ",vl_templateString,": ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
// check syntax: "abc $(macro_name) 2+$(macro_name)*(4-5)*(-2*0.5) def"
vl_templateString := "abc-$(macro_name) 2+$(macro_name)*(4-5)*(-2*0.5) def";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_templateString,pl_autoEVAL:=true);
vl_expected_value := "abc-3 "&float2str(5.0)&" def";
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong for template string ",vl_templateString,": ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
// check syntax: "abc $(macro_name) 2+$(macro_name)*(4-5)*(-2*0.5) def"
vl_templateString := "abc-$(macro_name) 2+$(macro_name)*(4-5)*(-2*0.5) def";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_templateString,pl_autoEVAL:=false);
vl_expected_value := "abc-3 2+3*(4-5)*(-2*0.5) def";
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong for template string ",vl_templateString,": ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
// check syntax: "abc $$(macro_name) 2+$$(macro_name)*(4-5)*(-2*0.5) def"
vl_templateString := "abc-$$(macro_name) 2+$$(macro_name)*(4-5)*(-2*0.5) def";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_templateString,pl_autoEVAL:=true);
vl_expected_value := "abc-5 "&float2str(7.0)&" def";
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong for template string ",vl_templateString,": ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
setverdict(pass,"Macros are successfully resolved");
f_EPTF_Base_stop(pass);
}
///////////////////////////////////////////////////////////
// Testcase: tc_EPTF_SMacro_Test_builtInMacro_EVAL_unsupportedArguments
//
// Purpose:
// to test EVAL built-in macro with expressions with unsupported arguments like 2.0%3.0
// they should remain in the output
//
// Requirement:
// -
//
// Action:
// - calls f_EPTF_SMacro_init_CT() function
// - calls f_EPTF_SMacro_define() function
// - checks the return value of f_EPTF_SMacro_resolve() when $EVAL is used
//
// Expected Result:
// - pass
///////////////////////////////////////////////////////////
testcase tc_EPTF_SMacro_Test_builtInMacro_EVAL_unsupportedArguments() runs on SMacro_Test_CT {
f_EPTF_SMacro_init_CT("SMacro_Test_builtInMacro_EVAL_unsupportedArguments");
var charstring vl_expressionString;
var charstring vl_templateString;
var charstring vl_resolved_value;
var charstring vl_expected_value;
action("*-----------------------------------------------------------------------------------------");
// check syntax: "$(EVAL , \"2.0%2.0\" )"
vl_expressionString := "2.0%2.0";
vl_templateString := "$("&c_EPTF_SMacro_macroName_EVAL&" , "&log2str(vl_expressionString)&" )";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_templateString);
vl_expected_value := vl_expressionString;
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong for template string ",vl_templateString,": ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
action("*-----------------------------------------------------------------------------------------");
// check syntax: "$(EVAL , \"abc2.0%2.0def1.0%2.0%3.0%ghi\" )"
vl_expressionString := "abc2.0%2.0def1.0%2.0%3.0%ghi";
vl_templateString := "$("&c_EPTF_SMacro_macroName_EVAL&" , "&log2str(vl_expressionString)&" )";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_templateString);
vl_expected_value := vl_expressionString;
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong for template string ",vl_templateString,": ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
action("*-----------------------------------------------------------------------------------------");
// check syntax: "$(EVAL , \"abc2.0%2.0*3.0%4.0+5%6.0efg\" )"
vl_expressionString := "abc2.0%2.0*3.0%4.0+5%6.0efg";
vl_templateString := "$("&c_EPTF_SMacro_macroName_EVAL&" , "&log2str(vl_expressionString)&" )";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_templateString);
vl_expected_value := "abc2.0%"&float2str(6.0)&"%"&float2str(9.0)&"%6.0efg";
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong for template string ",vl_templateString,": ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
action("*-----------------------------------------------------------------------------------------");
// check syntax: "$(EVAL , \"abc 2.0/0.0 1/0 efg\" )"
vl_expressionString := "abc 2.0/0.0 1/0 efg";
vl_templateString := "$("&c_EPTF_SMacro_macroName_EVAL&" , "&log2str(vl_expressionString)&" )";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_templateString);
vl_expected_value := "abc (EVAL: Error: Division by zero.) (EVAL: Error: Division by zero.) efg";
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong for template string ",vl_templateString,": ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
action("*-----------------------------------------------------------------------------------------");
// check syntax: "$(EVAL , \"2%0\" )"
vl_expressionString := "2%0";
vl_templateString := "$("&c_EPTF_SMacro_macroName_EVAL&" , "&log2str(vl_expressionString)&" )";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_templateString);
vl_expected_value := "(EVAL: Error: Division by zero.)";
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong for template string ",vl_templateString,": ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
setverdict(pass,"Macros are successfully resolved");
f_EPTF_Base_stop(pass);
}
///////////////////////////////////////////////////////////
// Testcase: tc_EPTF_SMacro_Test_builtInMacro_EVAL_wrongMathExpressions
//
// Purpose:
// to test EVAL built-in macro with wrong expressions
// they should remain in the output
//
// Requirement:
// -
//
// Action:
// - calls f_EPTF_SMacro_init_CT() function
// - calls f_EPTF_SMacro_define() function
// - checks the return value of f_EPTF_SMacro_resolve() when $EVAL is used
//
// Expected Result:
// - pass
///////////////////////////////////////////////////////////
testcase tc_EPTF_SMacro_Test_builtInMacro_EVAL_wrongMathExpressions() runs on SMacro_Test_CT {
f_EPTF_SMacro_init_CT("SMacro_Test_builtInMacro_EVAL_unsupportedArguments");
var charstring vl_expressionString;
var charstring vl_templateString;
var charstring vl_resolved_value;
var charstring vl_expected_value;
action("*-----------------------------------------------------------------------------------------");
// check syntax: "$(EVAL , \"a1+b b+1a\" )"
vl_expressionString := "a+b a1+b b+1a";
vl_templateString := "$("&c_EPTF_SMacro_macroName_EVAL&" , "&log2str(vl_expressionString)&" )";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_templateString);
vl_expected_value := "a+b a1+b b+1a";
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong for template string ",vl_templateString,": ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
action("*-----------------------------------------------------------------------------------------");
// check syntax: "$(EVAL , \"a*b a1*b b*1a a-+*b\" )"
vl_expressionString := "a*b a1*b b*1a a-+*b";
vl_templateString := "$("&c_EPTF_SMacro_macroName_EVAL&" , "&log2str(vl_expressionString)&" )";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_templateString);
vl_expected_value := "a*b a1*b b*1a a-+*b";
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong for template string ",vl_templateString,": ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
action("*-----------------------------------------------------------------------------------------");
// check syntax: "$(EVAL , \"a2+(2b a1)*2b a2*(3+4b a2+3)*4b a2*()+1b\" )"
vl_expressionString := "a2+(2b a1)*2b a2*(3+4b a2+3)*4b a2*()+1b";
vl_templateString := "$("&c_EPTF_SMacro_macroName_EVAL&" , "&log2str(vl_expressionString)&" )";
vl_resolved_value := f_EPTF_SMacro_resolve(vl_templateString);
vl_expected_value := "a2+(2b a1)*2b a2*(7b a5)*4b a2*()+1b";
if(vl_resolved_value != vl_expected_value) {
setverdict(fail,"Resolved value is wrong for template string ",vl_templateString,": ", vl_resolved_value, ". It should be: ", vl_expected_value);
f_EPTF_Base_stop(none);
}
setverdict(pass,"Macros are successfully resolved");
f_EPTF_Base_stop(pass);
}
//////////////////////// negative tests:
//----------------------------------------------------------------------------------------------------------------------------------------------------------
// Regexp test!!!! / Playground
//----------------------------------------------------------------------------------------------------------------------------------------------------------
const charstring c_EPTF_SMacro_macroParameter_ab := "(([^a]#(1, )|(a[^b]#(1,1))#(1,))#(0,))"; // macro parameter: asd1231!@$!@#$$MACRO sdsdg36" does not contain "ab"
const charstring c_EPTF_SMacro_macroParameter := "(([^\\\\]#(1, )|(\\\\[^\\\"]#(1,1))#(1,))#(0,))"; // macro parameter: asd1231!@$!@#$$MACRO sdsdg36" does not contain "ab"
// it tests the macro parameters
testcase tc_EPTF_SMacro_Test_c_EPTF_SMacro_macroParameter_ab() runs on SMacro_Test_CT {
// a: \\ , b: \"
var charstring vl_str_ab := "qwertyabqwerty_a_qweqw_a_qwer";
var charstring vl_str_ab1 := "qwertya_qwerty_ab_qweqw_a_qwer";
var charstring vl_str_ab2 := "qwertya_qwerty_a_qweqw_ab_qwer";
var charstring vl_str_ab3 := "qwertya_qwerty_ab_qweqw_aaab_qwer";
var charstring vl_str_NO_ab := "qwerty__qwerty_aa_qweqw_a_qwer_b_ghj";
var charstring vl_str_NO_ab2 := "qwerty__qwerty_aa_qweqw_a_qwer_b_ghja"; // not supported!! : ends with a
var charstring vl_str_NO_ab3 := "qwerty__qwerty__qweqw__qwer_b_ghj";
action("AB: ",regexp(vl_str_ab,c_EPTF_SMacro_macroParameter_ab,0));
action("AB1: ",regexp(vl_str_ab1,c_EPTF_SMacro_macroParameter_ab,0));
action("AB2: ",regexp(vl_str_ab2,c_EPTF_SMacro_macroParameter_ab,0));
action("AB3: ",regexp(vl_str_ab3,c_EPTF_SMacro_macroParameter_ab,0));
action("NOAB:",regexp(vl_str_NO_ab,c_EPTF_SMacro_macroParameter_ab,0));
action("NOAB2:",regexp(vl_str_NO_ab2,c_EPTF_SMacro_macroParameter_ab,0));
action("NOAB3:",regexp(vl_str_NO_ab3,c_EPTF_SMacro_macroParameter_ab,0));
if (regexp(vl_str_ab,c_EPTF_SMacro_macroParameter_ab,0)!= "") {
setverdict(fail, "Macro parameter ", vl_str_ab," is accepted as parameter but it is invalid");
stop;
}
if (regexp(vl_str_ab1,c_EPTF_SMacro_macroParameter_ab,0)!= "") {
setverdict(fail, "Macro parameter ", vl_str_ab1," is accepted as parameter but it is invalid");
stop;
}
if (regexp(vl_str_ab2,c_EPTF_SMacro_macroParameter_ab,0)!= "") {
setverdict(fail, "Macro parameter ", vl_str_ab2," is accepted as parameter but it is invalid");
stop;
}
if (regexp(vl_str_ab3,c_EPTF_SMacro_macroParameter_ab,0)!= "") {
setverdict(fail, "Macro parameter ", vl_str_ab3," is accepted as parameter but it is invalid");
stop;
}
if (regexp(vl_str_NO_ab,c_EPTF_SMacro_macroParameter_ab,0)!= vl_str_NO_ab) {
setverdict(fail, "Macro parameter ", vl_str_NO_ab," is not accepted as parameter but it is valid");
stop;
}
if (regexp(vl_str_NO_ab2,c_EPTF_SMacro_macroParameter_ab,0)!= vl_str_NO_ab2) {
action("Macro parameter ", vl_str_NO_ab2," is not accepted as parameter but it is valid, currently not supported");
}
if (regexp(vl_str_NO_ab3,c_EPTF_SMacro_macroParameter_ab,0)!= vl_str_NO_ab3) {
setverdict(fail, "Macro parameter ", vl_str_NO_ab3," is not accepted as parameter but it is valid");
stop;
}
action("AB: ",regexp(vl_str_ab,c_EPTF_SMacro_macroParameter_ab&c_EPTF_SMacro_everything,0));
action("AB1: ",regexp(vl_str_ab1,c_EPTF_SMacro_macroParameter_ab&c_EPTF_SMacro_everything,0));
action("AB2: ",regexp(vl_str_ab2,c_EPTF_SMacro_macroParameter_ab&c_EPTF_SMacro_everything,0));
action("AB3: ",regexp(vl_str_ab3,c_EPTF_SMacro_macroParameter_ab&c_EPTF_SMacro_everything,0));
action("NOAB:",regexp(vl_str_NO_ab,c_EPTF_SMacro_macroParameter_ab&c_EPTF_SMacro_everything,0));
action("NOAB2:",regexp(vl_str_NO_ab2,c_EPTF_SMacro_macroParameter_ab&c_EPTF_SMacro_everything,0));
action("NOAB3:",regexp(vl_str_NO_ab3,c_EPTF_SMacro_macroParameter_ab&c_EPTF_SMacro_everything,0));
setverdict(pass);
}
// it tests the macro parameters
testcase tc_EPTF_SMacro_Test_c_EPTF_SMacro_macroParameter() runs on SMacro_Test_CT {
// a: \\ , b: \"
var charstring vl_str_ab := "qwerty\\\"qwerty_\\_qweqw_\\_qwer";
var charstring vl_str_ab1 := "qwerty\\_qwerty_\\\"_qweqw_\\_qwer";
var charstring vl_str_ab2 := "qwerty\\_qwerty_\\_qweqw_\\\"_qwer";
var charstring vl_str_ab3 := "qwerty\\_qwerty_\\\"_qweqw_\\\\\\\"_qwer";
var charstring vl_str_NO_ab := "qwerty__qwerty_\\\\_qweqw_\\_qwer_\"_ghj";
var charstring vl_str_NO_ab2 := "qwerty__qwerty_\\\\_qweqw_\\_qwer_\"_ghj\\"; // not supported!! : ends with \\
var charstring vl_str_NO_ab3 := "qwerty__qwerty__qweqw__qwer_\"_ghj";
action("AB: ",regexp(vl_str_ab,c_EPTF_SMacro_macroParameter,0));
action("AB1: ",regexp(vl_str_ab1,c_EPTF_SMacro_macroParameter,0));
action("AB2: ",regexp(vl_str_ab2,c_EPTF_SMacro_macroParameter,0));
action("AB3: ",regexp(vl_str_ab3,c_EPTF_SMacro_macroParameter,0));
action("NOAB:",regexp(vl_str_NO_ab,c_EPTF_SMacro_macroParameter,0));
action("NOAB2:",regexp(vl_str_NO_ab2,c_EPTF_SMacro_macroParameter,0));
action("NOAB3:",regexp(vl_str_NO_ab3,c_EPTF_SMacro_macroParameter,0));
if (regexp(vl_str_ab,c_EPTF_SMacro_macroParameter,0)!= "") {
setverdict(fail, "Macro parameter ", vl_str_ab," is accepted as parameter but it is invalid");
stop;
}
if (regexp(vl_str_ab1,c_EPTF_SMacro_macroParameter,0)!= "") {
setverdict(fail, "Macro parameter ", vl_str_ab1," is accepted as parameter but it is invalid");
stop;
}
if (regexp(vl_str_ab2,c_EPTF_SMacro_macroParameter,0)!= "") {
setverdict(fail, "Macro parameter ", vl_str_ab2," is accepted as parameter but it is invalid");
stop;
}
if (regexp(vl_str_ab3,c_EPTF_SMacro_macroParameter,0)!= "") {
setverdict(fail, "Macro parameter ", vl_str_ab3," is accepted as parameter but it is invalid");
stop;
}
if (regexp(vl_str_NO_ab,c_EPTF_SMacro_macroParameter,0)!= vl_str_NO_ab) {
setverdict(fail, "Macro parameter ", vl_str_NO_ab," is not accepted as parameter but it is valid");
stop;
}
if (regexp(vl_str_NO_ab2,c_EPTF_SMacro_macroParameter,0)!= vl_str_NO_ab2) {
action("Macro parameter ", vl_str_NO_ab2," is not accepted as parameter but it is valid, currently not supported");
}
if (regexp(vl_str_NO_ab3,c_EPTF_SMacro_macroParameter,0)!= vl_str_NO_ab3) {
setverdict(fail, "Macro parameter ", vl_str_NO_ab3," is not accepted as parameter but it is valid");
stop;
}
action("AB: ",regexp(vl_str_ab,c_EPTF_SMacro_macroParameter&c_EPTF_SMacro_everything,0));
action("AB1: ",regexp(vl_str_ab1,c_EPTF_SMacro_macroParameter&c_EPTF_SMacro_everything,0));
action("AB2: ",regexp(vl_str_ab2,c_EPTF_SMacro_macroParameter&c_EPTF_SMacro_everything,0));
action("AB3: ",regexp(vl_str_ab3,c_EPTF_SMacro_macroParameter&c_EPTF_SMacro_everything,0));
action("NOAB:",regexp(vl_str_NO_ab,c_EPTF_SMacro_macroParameter&c_EPTF_SMacro_everything,0));
action("NOAB2:",regexp(vl_str_NO_ab2,c_EPTF_SMacro_macroParameter&c_EPTF_SMacro_everything,0));
action("NOAB3:",regexp(vl_str_NO_ab3,c_EPTF_SMacro_macroParameter&c_EPTF_SMacro_everything,0));
setverdict(pass);
}
const charstring c_EPTF_SMacro_macroWithParameters := "[$]#(1,1)\(("&c_EPTF_SMacro_macroNameRegexp&c_EPTF_SMacro_whitespace&","&c_EPTF_SMacro_whitespace
&"("""&c_EPTF_SMacro_macroParameter& """)#(1,1)"
// // &"(,"&c_EPTF_SMacro_whitespace&""""&c_EPTF_SMacro_macroParameter& """)#(0,)"
&c_EPTF_SMacro_whitespace&")\)"; // macro with () name: $(abcdABCD_0123)
const charstring c_EPTF_SMacro_macroGeneric := "("&c_EPTF_SMacro_macroWithParameters&")";
// it tests the macro parameters
testcase tc_EPTF_SMacro_Test_c_EPTF_SMacro_macroGeneric() runs on SMacro_Test_CT {
var charstring vl_macro0 := "$MACRO0";
var charstring vl_macro1 := "$(MACRO1)";
var charstring vl_macro2 := "$(MACRO2, \" par1 \" )"; // -> f_MACRO2(pl_args:= {" par1 "})
var charstring vl_macro2b := "$(MACRO2b, \" par1 \", \" par2 \" )"; // -> f_MACRO2(pl_args:= {" par1 ", " par2 ""})
var charstring vl_macro3 := "$(MACRO3, \" $(MACRO2, \\\" par1 \\\") \" )"; // -> f_MACRO3(pl_args:= {" $(MACRO2, \" par1 \") " }) -> f_MACRO3(pl_args:= " "&f_MACRO2(pl_args := { " par1 "})&" ")
action("Macro 0: ",regexp(vl_macro0,c_EPTF_SMacro_macroGeneric,0));
action("Macro 1: ",regexp(vl_macro1,c_EPTF_SMacro_macroGeneric,0));
action("Macro 2: ",regexp(vl_macro2,c_EPTF_SMacro_macroGeneric,0));
action("Macro 2b: ",regexp(vl_macro2b,c_EPTF_SMacro_macroGeneric,0));
action("Macro 3: ",regexp(vl_macro3,c_EPTF_SMacro_macroGeneric,0));
setverdict(pass);
}
//=========================================================================
// Control
//=========================================================================
control {
execute(tc_EPTF_SMacro_Test_init());
execute(tc_EPTF_SMacro_Test_invalidMacroName());
execute(tc_EPTF_SMacro_Test_invalidMacroNameWithLoggingInitialized());
execute(tc_EPTF_SMacro_Test_reDefineMacro());
execute(tc_EPTF_SMacro_Test_unDefineMacro());
execute(tc_EPTF_SMacro_Test_unDefineUnknownMacro());
execute(tc_EPTF_SMacro_Test_registerCalcFn_defaultFnName());
execute(tc_EPTF_SMacro_Test_registerCalcFn_existingFnName());
execute(tc_EPTF_SMacro_Test_deregisterCalcFn());
execute(tc_EPTF_SMacro_Test_deregisterUnknownCalcFn());
execute(tc_EPTF_SMacro_Test_resolveMacro());
execute(tc_EPTF_SMacro_Test_resolveMacro_checkWrongMacroSyntax());
execute(tc_EPTF_SMacro_Test_builtInMacro_EVAL_SingleExpressions());
execute(tc_EPTF_SMacro_Test_autoEVAL());
execute(tc_EPTF_SMacro_Test_builtInMacro_EVAL_unsupportedArguments());
execute(tc_EPTF_SMacro_Test_builtInMacro_EVAL_wrongMathExpressions());
}
} // module