diff options
Diffstat (limited to 'Swiften/QA/UnitTest')
-rw-r--r-- | Swiften/QA/UnitTest/Makefile.inc | 17 | ||||
-rw-r--r-- | Swiften/QA/UnitTest/checker.cpp | 16 | ||||
-rw-r--r-- | Swiften/QA/UnitTest/template/FooTest.cpp | 24 |
3 files changed, 57 insertions, 0 deletions
diff --git a/Swiften/QA/UnitTest/Makefile.inc b/Swiften/QA/UnitTest/Makefile.inc new file mode 100644 index 0000000..5b456db --- /dev/null +++ b/Swiften/QA/UnitTest/Makefile.inc @@ -0,0 +1,17 @@ +UNITTEST_TARGET = Swiften/QA/UnitTest/checker +UNITTEST_SOURCES += \ + Swiften/QA/UnitTest/checker.cpp +UNITTEST_OBJECTS = \ + $(UNITTEST_SOURCES:.cpp=.o) + +TEST_TARGETS += check + +CLEANFILES += $(UNITTEST_OBJECTS) $(UNITTEST_TARGET) + +.PHONY: check +check: $(UNITTEST_TARGET) + $(TEST_RUNNER) ./$(UNITTEST_TARGET) + +$(UNITTEST_TARGET): $(SWIFTEN_TARGET) $(CPPUNIT_TARGET) $(UNITTEST_OBJECTS) + $(QUIET_LINK)$(CXX) -o $(UNITTEST_TARGET) $(UNITTEST_OBJECTS) $(LDFLAGS) $(SWIFTEN_TARGET) $(CPPUNIT_TARGET) $(LIBS) + diff --git a/Swiften/QA/UnitTest/checker.cpp b/Swiften/QA/UnitTest/checker.cpp new file mode 100644 index 0000000..ea4f0d9 --- /dev/null +++ b/Swiften/QA/UnitTest/checker.cpp @@ -0,0 +1,16 @@ +#include <string> +#include <cppunit/ui/text/TestRunner.h> +#include <cppunit/extensions/TestFactoryRegistry.h> +#include <cppunit/XmlOutputter.h> +#include <cppunit/TextTestResult.h> + +int main(int argc, char* argv[]) +{ + CppUnit::TestFactoryRegistry& registry = CppUnit::TestFactoryRegistry::getRegistry(); + CppUnit::TextUi::TestRunner runner; + runner.addTest( registry.makeTest() ); + if (argc >= 2 && std::string(argv[1]) != std::string("--xml")) { + runner.setOutputter(new CppUnit::XmlOutputter(&runner.result(), std::cout)); + } + return (runner.run("") ? 0 : 1); +} diff --git a/Swiften/QA/UnitTest/template/FooTest.cpp b/Swiften/QA/UnitTest/template/FooTest.cpp new file mode 100644 index 0000000..b6b9abf --- /dev/null +++ b/Swiften/QA/UnitTest/template/FooTest.cpp @@ -0,0 +1,24 @@ +#include <cppunit/extensions/HelperMacros.h> +#include <cppunit/extensions/TestFactoryRegistry.h> + +using namespace Swift; + +class FooTest : public CppUnit::TestFixture { + CPPUNIT_TEST_SUITE(FooTest); + CPPUNIT_TEST(testBar); + CPPUNIT_TEST_SUITE_END(); + + public: + FooTest() {} + + void setUp() { + } + + void tearDown() { + } + + void testBar() { + } +}; + +CPPUNIT_TEST_SUITE_REGISTRATION(FooTest); |