testing: Various fixes to make the tests compile without warnings/errors
This commit is contained in:
parent
fb5707b73e
commit
b235c373a5
4
Makefile
4
Makefile
|
@ -7,7 +7,7 @@ TESTS=testbufferoverrun.o testcharvar.o testconstructors.o testdivision.o testme
|
||||||
|
|
||||||
all: ${OBJS} main.o
|
all: ${OBJS} main.o
|
||||||
g++ -Wall -g -o cppcheck $^
|
g++ -Wall -g -o cppcheck $^
|
||||||
test: ${OBJS} TestsRunner.o MiniCppUnit.o ${TESTS}
|
test: ${OBJS} testrunner.o testsuite.o ${TESTS}
|
||||||
g++ -Wall -g -o testsrunner $^
|
g++ -Wall -g -o testrunner $^
|
||||||
clean:
|
clean:
|
||||||
rm -f *.o cppcheck_test cppcheck
|
rm -f *.o cppcheck_test cppcheck
|
||||||
|
|
|
@ -319,6 +319,6 @@ private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
REGISTER_TEST( TestBufferOverrun );
|
REGISTER_TEST( TestBufferOverrun )
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -77,5 +77,5 @@ private:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
REGISTER_TEST( TestCharVar );
|
REGISTER_TEST( TestCharVar )
|
||||||
|
|
||||||
|
|
|
@ -97,4 +97,4 @@ private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
REGISTER_TEST( TestConstructors );
|
REGISTER_TEST( TestConstructors )
|
||||||
|
|
|
@ -128,6 +128,6 @@ private:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
REGISTER_TEST( TestDivision );
|
REGISTER_TEST( TestDivision )
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -542,6 +542,6 @@ private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
REGISTER_TEST( TestMemleak );
|
REGISTER_TEST( TestMemleak )
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -53,10 +53,12 @@ TestFixture::TestFixture(const std::string &_name) : classname(_name)
|
||||||
TestRegistry::theInstance().addTest(this);
|
TestRegistry::theInstance().addTest(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
TestFixture::~TestFixture()
|
TestFixture::~TestFixture()
|
||||||
{
|
{
|
||||||
TestRegistry::theInstance().removeTest(this);
|
TestRegistry::theInstance().removeTest(this);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
bool TestFixture::runTest(const char testname[])
|
bool TestFixture::runTest(const char testname[])
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,7 +19,7 @@ protected:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TestFixture(const std::string &_name);
|
TestFixture(const std::string &_name);
|
||||||
~TestFixture();
|
virtual ~TestFixture() { }
|
||||||
|
|
||||||
static void printTests();
|
static void printTests();
|
||||||
static void runTests();
|
static void runTests();
|
||||||
|
@ -28,5 +28,5 @@ public:
|
||||||
|
|
||||||
#define TEST_CASE( NAME ) if ( runTest(#NAME) ) NAME ();
|
#define TEST_CASE( NAME ) if ( runTest(#NAME) ) NAME ();
|
||||||
#define ASSERT_EQUALS( EXPECTED , ACTUAL ) if (EXPECTED!=ACTUAL) assertFail(__FILE__, __LINE__);
|
#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; }
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
// Check for unused variables..
|
// Check for unused variables..
|
||||||
|
|
||||||
#include "MiniCppUnit.h"
|
#include "testsuite.h"
|
||||||
#include "tokenize.h"
|
#include "tokenize.h"
|
||||||
#include "CheckOther.h"
|
#include "CheckOther.h"
|
||||||
|
|
||||||
|
@ -9,8 +9,12 @@
|
||||||
|
|
||||||
extern std::ostringstream errout;
|
extern std::ostringstream errout;
|
||||||
|
|
||||||
class TestUnusedVar : public TestFixture<TestUnusedVar>
|
class TestUnusedVar : public TestFixture
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
TestUnusedVar() : TestFixture("TestUnusedVar")
|
||||||
|
{ }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void check( const char code[] )
|
void check( const char code[] )
|
||||||
{
|
{
|
||||||
|
@ -27,8 +31,7 @@ private:
|
||||||
CheckStructMemberUsage();
|
CheckStructMemberUsage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
void run()
|
||||||
TEST_FIXTURE( TestUnusedVar )
|
|
||||||
{
|
{
|
||||||
TEST_CASE( structmember1 );
|
TEST_CASE( structmember1 );
|
||||||
}
|
}
|
||||||
|
@ -48,6 +51,6 @@ public:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
REGISTER_FIXTURE( TestUnusedVar )
|
REGISTER_TEST( TestUnusedVar )
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue