我的最终目标是覆盖下面的代码(使完整的代码变成绿色)。我正在使用康塔塔工具。
#define CHECK1 ((a == 1) || (a == 4))
void check_fun(int a, int b)
{
if((!CHECK1)&&(b>0)&&(b<10))
{
}
}
我写了5个测试用例如下
void test_check_fun(int doIt){
if (doIt) {
/* Test case data declarations */
int a;
int b;
START_TEST("test_check_fun_001",
"<Entry condition: True check for if((!((a == 1) || (a == 4)))&&(b>0)&&(b<10)) ((!(F||F))&&(T)&&(T)) equalent to (T&&T&&T)>");
/* Expected Call Sequence */
EXPECTED_CALLS("");
/* Set global data */
initialise_global_data();
a = 3;
b = 5;
/* Set expected values for global data checks */
initialise_expected_global_data();
/* Call SUT */
check_fun(a, b);
/* Test case checks */
/* Checks on global data */
check_global_data();
END_CALLS();
END_TEST();
START_TEST("test_check_fun_002",
"<Entry condition: False check for if((!((a == 1) || (a == 4)))&&(b>0)&&(b<10)) ((!(T||F))&&(T)&&(T)) equalent to (F&&T&&T)>");
/* Expected Call Sequence */
EXPECTED_CALLS("");
/* Set global data */
initialise_global_data();
a = 1;
b = 5;
/* Set expected values for global data checks */
initialise_expected_global_data();
/* Call SUT */
check_fun(a, b);
/* Test case checks */
/* Checks on global data */
check_global_data();
END_CALLS();
END_TEST();
START_TEST("test_check_fun_003",
"<Entry condition: False check for if((!((a == 1) || (a == 4)))&&(b>0)&&(b<10)) ((!(F||T))&&(T)&&(T)) equalent to (F&&T&&T)>");
/* Expected Call Sequence */
EXPECTED_CALLS("");
/* Set global data */
initialise_global_data();
a = 4;
b = 5;
/* Set expected values for global data checks */
initialise_expected_global_data();
/* Call SUT */
check_fun(a, b);
/* Test case checks */
/* Checks on global data */
check_global_data();
END_CALLS();
END_TEST();
START_TEST("test_check_fun_004",
"<Entry condition: False check for if((!((a == 1) || (a == 4)))&&(b>0)&&(b<10)) ((!(F||F))&&(F)&&(T)) equalent to (T&&F&&T)>");
/* Expected Call Sequence */
EXPECTED_CALLS("");
/* Set global data */
initialise_global_data();
a = 3;
b = -1;
/* Set expected values for global data checks */
initialise_expected_global_data();
/* Call SUT */
check_fun(a, b);
/* Test case checks */
/* Checks on global data */
check_global_data();
END_CALLS();
END_TEST();
START_TEST("test_check_fun_005",
"<Entry condition: False check for if((!((a == 1) || (a == 4)))&&(b>0)&&(b<10)) ((!(F||F))&&(T)&&(F)) equalent to (T&&T&&F)>");
/* Expected Call Sequence */
EXPECTED_CALLS("");
/* Set global data */
initialise_global_data();
a = 3;
b = 11;
/* Set expected values for global data checks */
initialise_expected_global_data();
/* Call SUT */
check_fun(a, b);
/* Test case checks */
/* Checks on global data */
check_global_data();
END_CALLS();
END_TEST();
}}
结果显示为
===========================================================================
= Cantata Test Harness v6.2 =
= (c) 2012 QA Systems GmbH =
=-------------------------------------------------------------------------=
= Test Description: check =
= Log File: test_check.ctr =
= Test Started: Wed Jun 24 12:10:56 2015 =
===========================================================================
===========================================================================
= Test Finished: Wed Jun 24 12:10:56 2015 =
=-------------------------------------------------------------------------=
= Test Script Checks Checks Checks Call Seq TEST =
= Case Errors Failed Passed Warned Failures RESULT =
=-------------------------------------------------------------------------=
= test_check_fun_001 0 0 0 3 0 PASS =
= test_check_fun_002 0 0 0 3 0 PASS =
= test_check_fun_003 0 0 0 3 0 PASS =
= test_check_fun_004 0 0 0 3 0 PASS =
= test_check_fun_005 0 0 0 3 0 PASS =
= Other 0 0 4 0 0 PASS =
=-------------------------------------------------------------------------=
= TOTALS 0 0 4 15 0 PASS =
===========================================================================
我的问题是一些代码没有显示为绿色。所以请告诉我我错过了哪些测试用例来涵盖以下条件
if((!((a == 1) || (a == 4)))&&(b>0)&&(b<10))
请帮助我。提前致谢。