这是造成悲伤的;我想和cunit一起握住。
已使用以下说明安装了它:http://macappstore.org/cunit/
我正在使用以下命令行:gcc myprog.c -wall -wfloat -equal -wextra -o2 -pedistic -pedantic -ansi -lm -lcunit -o myprog
它没有错误编译,我继续进行以下操作:./myprog
我有以下坐在我的代码中:
#include <stdio.h>
#include <math.h>
#include <CUnit/CUnit.h>
int maxi(int i1, int i2);
void test_maxi(void);
struct code{
char words[5][5];
int cnt; /* Current Word Counter*/
};
typedef struct code Code;
int main(void){
test_maxi();
return 0;
}
int maxi(int i1, int i2){
return (i1 > i2) ? i1 : i2;
}
void test_maxi(void){
CU_ASSERT(maxi(0,2) == 2);
CU_ASSERT(maxi(0,-2) == 0);
CU_ASSERT(maxi(2,2) == 2);
}
我的假设是,这应该在同一目录中生成某种.txt或替代文件。这个假设不正确吗?我应该寻找什么?
更新:我当前正在命令行中获得以下内容;"断言失败:( null!= f_pcursuite),函数cu_assertimplementation,文件testrun.c,第162行。中止陷阱:6"
(全面披露:编程的新知识....所以要温柔:P)
您没有在main()
中调用test_maxi
,因此它只是作为一个函数而存在,但没有运行。您需要在main
中运行它。 &ndash;&nbsp; eli sadoff
您需要创建一个如下所述的测试套件。 &ndash;&nbsp; pbn