eseses455250704 2015-08-26 07:51 采纳率: 0%
浏览 1547

C语言 应该怎么修改宏定义 在函数5执行之后,打印错误error 函数6也能执行

这是函数5
static char * test_replace()
{
Link_t head;
head = LinkTable_new();
Link_t temp3 =Link_replace(head, "101", "cpp101");
int number4;
if(temp3 != NULL)
{
number4 =2;
}
else
{
number4 =0;
}
if(number4 == 1)
{
passed++;
}
else
{
failed++;
}
tcut_assert("error, number4 != 1", number4 == 1);
return 0;
}

这是函数6

static char * test_remove()
{
Link_t head;
head = LinkTable_new();
Link_t temp = Link_remove(head, "102");
Link_t temp2 = Link_remove(head, "102");
int number5;
if(temp2 == NULL)
{
number5=1;
}
if(head == temp)
{
LinkTable_free(head);
}
else
{
free(temp);
LinkTable_free(head);
}
if(number5 == 1)
{
passed++;
}
else
{
failed++;
}
tcut_assert("error, number5 != 1", number5 == 1);
return 0;
}

static char * all_tests()
{

tcut_run_test(test_replace);
tcut_run_test(test_remove);
return 0;
}

int main(int argc, char **argv)
{
printf("\n----------- Begin Unit Test ----------\n");
Test_LinkTable( );
char *result = all_tests();
printf("Tests run: %d\n", nr_tests);
if (result != 0)
{
printf("%s\n", result);
printf("Error:The test doesn't pass normal");
}
else
{
printf("ALL TESTS PASSED\n");
}
printf("\n------------End Unit Test -------------\n");
printf("Passed: %d 个 \n",passed);
printf("Failed: %d 个 \n",failed);
printf("\n----------------------------------------\n");
return result != 0;
}

宏定义 :#define tcut_assert(what, test) do { if (!(test)) return what;} while (0)
#define tcut_run_test(test) do { char *what = test(); nr_tests++; if (what) return what; } while (0)

应该怎么改宏定义 让函数5不执行 函数 6可以执行

  • 写回答

1条回答 默认 最新

  • 纵横车 2015-08-26 08:06
    关注

    if (what) return what;前面加一行调用函数6的代码。

    评论

报告相同问题?

悬赏问题

  • ¥15 有赏,i卡绘世画不出
  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入
  • ¥40 使用MATLAB解答线性代数问题
  • ¥15 COCOS的问题COCOS的问题
  • ¥15 FPGA-SRIO初始化失败
  • ¥15 MapReduce实现倒排索引失败
  • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
  • ¥15 找一位技术过硬的游戏pj程序员
  • ¥15 matlab生成电测深三层曲线模型代码