我正在尝试编写一个简单的代码来测试“创建函数”,但是当我使用assert
时出现此错误:函数assert无法解析。函数“assert”无法解析
这是我的代码:
#include "Participant.h"
#include "ParticipantValidator.h"
#include <assert.h>
void testCreateParticipant()
{
Participant part(1, "Corina", "Marin", 5);
assert(part.getId() == 1);
assert(part.getScore() == 5);
assert(part.getName() == "Corina");
assert(part.getFamilyName() == "Marin");
}
为什么不使用单元测试框架 - 即boost_unit或CPP单元例如 –
@EdHeal:也许是因为断言不只是为了测试,但也是在产品构建有用。 –
@ user3316022:尝试通过在自包含的,编译的示例再现错误的错误隔离。如果Participant.h的内容不太大,请手动包含它们。检查ParticipantValidator.h是否相关。如果没有,请删除理想情况下,你拿出一个完整的方案以'主()'函数复制正pastable在大致符合一个浏览器屏幕上一个* .cpp文件:) –