我想重寫一些遺留的C代碼,並想在實際開始重寫之前進行一些測試。爲了這個,我看了看CppUTest並試圖組成一個頭文件chrtostr.h
的一個示例應用程序,實現文件chrtostr.c
和測試文件名爲其內容羅列如下test_chrtostr.c
:CppUTest不工作
#include <CppUTest/CommandLineTestRunner.h>
#include "chrtostr.h"
TEST_GROUP(chrtostr)
{
}
TEST(chrtostr, test_chrtostr)
{
CHECK_EQUAL(chrtostr('n'), "sfsdfds");
}
int main(int ac, char **av)
{
return CommandLineTestRunner::RunAllTests(ac, av);
}
和相應的Makefile.am
:
AUTOMAKE_OPTIONS = foreign
CPPUTEST_HOME = ./cpputest
CFLAGS = -g -Wall -I$(CPPUTEST_HOME)/include
LDFLAGS = -L$(CPPUTEST_HOME)/lib -lCppUTest
bin_PROGRAMS = chrtostr test_chrtostr
chrtostr_SOURCES = chrtostr.c chrtostr.h main.c
test_chrtostr_SOURCES = test_chrtostr.c
的問題是,每次我嘗試運行make
我得到以下回溯,它實際上並不幫助我太多:http://pastebin.com/BK9ts3vk
格兒,那麼爲什麼他們主張它作爲一個C和C++單元測試框架?謝謝你! – hyperboreean 2011-04-09 10:24:27
因爲你可以用它來測試C代碼。 – Mat 2011-04-09 10:25:14
是的,但是如果我有純粹的C代碼,我只想用gcc編譯*而不是g ++,那麼這是一種痛苦。 C和C++不是同一種語言。 – hyperboreean 2011-04-09 10:28:10