From b235c373a513a31c6d2649bd16a2947a01e80f47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 16 Oct 2008 17:22:26 +0000 Subject: [PATCH] testing: Various fixes to make the tests compile without warnings/errors --- Makefile | 4 ++-- testbufferoverrun.cpp | 2 +- testcharvar.cpp | 2 +- testconstructors.cpp | 2 +- testdivision.cpp | 2 +- testmemleak.cpp | 2 +- testsuite.cpp | 2 ++ testsuite.h | 4 ++-- testunusedvar.cpp | 13 ++++++++----- 9 files changed, 19 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index 8375b3214..bc2dffe08 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ TESTS=testbufferoverrun.o testcharvar.o testconstructors.o testdivision.o testme all: ${OBJS} main.o g++ -Wall -g -o cppcheck $^ -test: ${OBJS} TestsRunner.o MiniCppUnit.o ${TESTS} - g++ -Wall -g -o testsrunner $^ +test: ${OBJS} testrunner.o testsuite.o ${TESTS} + g++ -Wall -g -o testrunner $^ clean: rm -f *.o cppcheck_test cppcheck diff --git a/testbufferoverrun.cpp b/testbufferoverrun.cpp index 112100d1b..d50d28474 100644 --- a/testbufferoverrun.cpp +++ b/testbufferoverrun.cpp @@ -319,6 +319,6 @@ private: }; -REGISTER_TEST( TestBufferOverrun ); +REGISTER_TEST( TestBufferOverrun ) diff --git a/testcharvar.cpp b/testcharvar.cpp index c75988b13..1085be3a6 100644 --- a/testcharvar.cpp +++ b/testcharvar.cpp @@ -77,5 +77,5 @@ private: } }; -REGISTER_TEST( TestCharVar ); +REGISTER_TEST( TestCharVar ) diff --git a/testconstructors.cpp b/testconstructors.cpp index 447c9b53b..963312a57 100644 --- a/testconstructors.cpp +++ b/testconstructors.cpp @@ -97,4 +97,4 @@ private: }; -REGISTER_TEST( TestConstructors ); +REGISTER_TEST( TestConstructors ) diff --git a/testdivision.cpp b/testdivision.cpp index 506de5a7a..97c588681 100644 --- a/testdivision.cpp +++ b/testdivision.cpp @@ -128,6 +128,6 @@ private: } }; -REGISTER_TEST( TestDivision ); +REGISTER_TEST( TestDivision ) diff --git a/testmemleak.cpp b/testmemleak.cpp index ed6b9b6de..45830dd02 100644 --- a/testmemleak.cpp +++ b/testmemleak.cpp @@ -542,6 +542,6 @@ private: }; -REGISTER_TEST( TestMemleak ); +REGISTER_TEST( TestMemleak ) diff --git a/testsuite.cpp b/testsuite.cpp index b206236da..3a1df4abc 100644 --- a/testsuite.cpp +++ b/testsuite.cpp @@ -53,10 +53,12 @@ TestFixture::TestFixture(const std::string &_name) : classname(_name) TestRegistry::theInstance().addTest(this); } +/* TestFixture::~TestFixture() { TestRegistry::theInstance().removeTest(this); } +*/ bool TestFixture::runTest(const char testname[]) { diff --git a/testsuite.h b/testsuite.h index 83ba65064..0b2af5316 100644 --- a/testsuite.h +++ b/testsuite.h @@ -19,7 +19,7 @@ protected: public: TestFixture(const std::string &_name); - ~TestFixture(); + virtual ~TestFixture() { } static void printTests(); static void runTests(); @@ -28,5 +28,5 @@ public: #define TEST_CASE( NAME ) if ( runTest(#NAME) ) NAME (); #define ASSERT_EQUALS( EXPECTED , ACTUAL ) if (EXPECTED!=ACTUAL) assertFail(__FILE__, __LINE__); -#define REGISTER_TEST( CLASSNAME ) namespace { CLASSNAME instance; }; +#define REGISTER_TEST( CLASSNAME ) namespace { CLASSNAME instance; } diff --git a/testunusedvar.cpp b/testunusedvar.cpp index 19716b8fc..d0eb835b4 100644 --- a/testunusedvar.cpp +++ b/testunusedvar.cpp @@ -1,7 +1,7 @@ // Check for unused variables.. -#include "MiniCppUnit.h" +#include "testsuite.h" #include "tokenize.h" #include "CheckOther.h" @@ -9,8 +9,12 @@ extern std::ostringstream errout; -class TestUnusedVar : public TestFixture +class TestUnusedVar : public TestFixture { +public: + TestUnusedVar() : TestFixture("TestUnusedVar") + { } + private: void check( const char code[] ) { @@ -27,8 +31,7 @@ private: CheckStructMemberUsage(); } -public: - TEST_FIXTURE( TestUnusedVar ) + void run() { TEST_CASE( structmember1 ); } @@ -48,6 +51,6 @@ public: }; -REGISTER_FIXTURE( TestUnusedVar ) +REGISTER_TEST( TestUnusedVar )