--ypfish.blog.chinaunix.net
stone_pub
全部博文(138)
book(2)
ruby(1)
python(2)
bat(2)
vbscript(1)
javascript(5)
html(1)
shell(11)
c++(16)
test(1)
office(3)
cdrecord(2)
firefox(0)
GIMP(1)
Emacs(1)
VI(2)
resume(2)
tinyxml(1)
libcurl(2)
上海(2)
dba(3)
2016年(5)
2014年(4)
2012年(1)
2011年(2)
2010年(10)
2009年(19)
2008年(97)
zc7h
xy1121
老男孩IT
cynthia
wrathpig
Phyllis6
Bsolar
牛平
doctorle
hanzhenl
jiangbin
分类: C/C++
2008-04-03 16:18:48
AC_PREREQ(2.57) AC_INIT(test, 1.1, stone.pub@163.com) AM_INIT_AUTOMAKE(test, 1.1) # AC_CONFIG_SRCDIR([main.cpp]) # AC_CONFIG_HEADER([config.h]) AC_PROG_CXXAC_OUTPUT(Makefile)
AC_PREREQ(2.57) AC_INIT(test, 1.1, stone.pub@163.com) AM_INIT_AUTOMAKE(test, 1.1) AC_CONFIG_SRCDIR([mytest]) AC_PROG_RANLIB AC_PROG_CXX AC_PROG_LIBTOOL AC_LTDL_DLLIB AC_OUTPUT([ Makefile mytest/Makefile])
test_SOURCES=main.cpp MyTest.cpp test_LDFLAGS=-lcppunit -ldl -L/usr/local/lib
# AM_CXXFLAGS = -D_LINUX
#
# INCLUDES=-IPassport
# SUBDIRS = dir1
# test_LDADD = libsub1.a
lib_LTLIBRARIES = libmytest.la libmytest_la_SOURCES = MyTest.cpp INCLUDES=-I../include
//#include #include <cppunit/TestResult.h> #include <cppunit/TestResultCollector.h> #include <cppunit/TestRunner.h> //#include #include <cppunit/BriefTestProgressListener.h> //#include #include <cppunit/extensions/TestFactoryRegistry.h> //#include //#include int main( int argc, char **argv ) { // Create the event manager and test controller CPPUNIT_NS::TestResult controller; // Add a listener that colllects test result CPPUNIT_NS::TestResultCollector result; controller.addListener( &result ); // Add a listener that print dots as test run. CPPUNIT_NS::BriefTestProgressListener progress; controller.addListener( &progress ); // Add the top suite to the test runner CPPUNIT_NS::TestRunner runner; runner.addTest( CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest() ); runner.run( controller ); return result.wasSuccessful() ? 0 : 1; }
#include <cppunit/config/SourcePrefix.h> #include "MyTest.h" CPPUNIT_TEST_SUITE_REGISTRATION( MyTest ); MyTest::MyTest() { } MyTest::~MyTest() { } void MyTest::test1() { std::string expected = "1234.56"; std::string actual = CPPUNIT_NS::StringTools::toString(1234.56); CPPUNIT_ASSERT_EQUAL(expected, actual); }
#ifndef MYTEST_H #define MYTEST_H #include <cppunit/extensions/HelperMacros.h> #include <cppunit/tools/StringTools.h> class MyTest : public CPPUNIT_NS::TestCase { CPPUNIT_TEST_SUITE( MyTest ); CPPUNIT_TEST( test1 ); CPPUNIT_TEST_SUITE_END(); public: MyTest(); virtual ~MyTest(); void test1(); private: MyTest(const MyTest& other); void operator=(const MyTest &other); }; #endif
上一篇:pragma
下一篇:Test
登录 注册