Skip to content

Instantly share code, notes, and snippets.

@Lewuathe
Created January 12, 2013 00:39
Show Gist options
  • Save Lewuathe/4515294 to your computer and use it in GitHub Desktop.
Save Lewuathe/4515294 to your computer and use it in GitHub Desktop.
CXX=g++
LIBS=-lcppunit
SOURCES=someTest.cc some.cc
TARGETS=mainTest
all :
g++ -o mainTest mainTest.cc $(SOURCES) $(LIBS)
clean :
rm $(TARGET)
#include <cppunit/TestResult.h>
#include <cppunit/TestResultCollector.h>
#include <cppunit/BriefTestProgressListener.h>
#include <cppunit/TestRunner.h>
#include <cppunit/extensions/TestFactoryRegistry.h>
#include <cppunit/CompilerOutputter.h>
using namespace CPPUNIT_NS;
int main(int argc, char **argv) {
TestResult controller;
TestResultCollector result;
controller.addListener(&result);
BriefTestProgressListener progress;
controller.addListener(&progress);
TestRunner runner;
runner.addTest(TestFactoryRegistry::getRegistry().makeTest());
runner.run(controller);
CompilerOutputter outputter(&result, stdCOut());
outputter.write();
return result.wasSuccessful() ? 0 : 1;
}
bool some(bool tf){
return !tf;
}
#include "some.cc"
#include <cppunit/extensions/HelperMacros.h>
using namespace CPPUNIT_NS;
class someTest : public TestFixture {
CPPUNIT_TEST_SUITE(someTest);
CPPUNIT_TEST(test1);
CPPUNIT_TEST(test2);
CPPUNIT_TEST_SUITE_END();
void test1(){
CPPUNIT_ASSERT( some(true) == false );
}
void test2(){
CPPUNIT_ASSERT( some(false) == true );
}
};
CPPUNIT_TEST_SUITE_REGISTRATION(reverseTest);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment