diff ext/UnitTest++/src/tests/TestTest.cpp @ 37:0d325e9d5953

added unittest++ files into ext. Not hooked into build scripts yet
author jasoka@33b003aa-7bff-0310-803a-e67f0ece8222
date Sat, 12 Jul 2008 12:00:57 +0000
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ext/UnitTest++/src/tests/TestTest.cpp	Sat Jul 12 12:00:57 2008 +0000
@@ -0,0 +1,97 @@
+#include "../UnitTest++.h"
+#include "../TestReporter.h"
+#include "../TimeHelpers.h"
+
+using namespace UnitTest;
+
+namespace {
+
+TEST (PassingTestHasNoFailures)
+{
+    class PassingTest : public Test
+    {
+    public:
+        PassingTest() : Test("passing") {}
+        virtual void RunImpl(TestResults& testResults_) const
+        {
+            CHECK(true);
+        }
+    };
+
+    TestResults results;
+    PassingTest().Run(results);
+    CHECK_EQUAL(0, results.GetFailureCount());
+}
+
+
+TEST (FailingTestHasFailures)
+{
+    class FailingTest : public Test
+    {
+    public:
+        FailingTest() : Test("failing") {}
+        virtual void RunImpl(TestResults& testResults_) const
+        {
+            CHECK(false);
+        }
+    };
+
+    TestResults results;
+    FailingTest().Run(results);
+    CHECK_EQUAL(1, results.GetFailureCount());
+}
+
+
+TEST (ThrowingTestsAreReportedAsFailures)
+{
+    class CrashingTest : public Test
+    {
+    public:
+        CrashingTest() : Test("throwing") {}
+        virtual void RunImpl(TestResults&) const
+        {
+            throw "Blah";
+        }
+    };
+ 
+    TestResults results;
+    CrashingTest().Run(results);
+    CHECK_EQUAL(1, results.GetFailureCount());
+}
+
+
+#ifndef UNITTEST_MINGW
+TEST (CrashingTestsAreReportedAsFailures)
+{
+    class CrashingTest : public Test
+    {
+    public:
+        CrashingTest() : Test("crashing") {}
+        virtual void RunImpl(TestResults&) const
+        {
+            reinterpret_cast< void (*)() >(0)();
+        }
+    };
+
+    TestResults results;
+    CrashingTest().Run(results);
+    CHECK_EQUAL(1, results.GetFailureCount());
+}
+#endif
+
+TEST (TestWithUnspecifiedSuiteGetsDefaultSuite)
+{
+    Test test("test");
+    CHECK(test.m_details.suiteName != NULL);
+    CHECK_EQUAL("DefaultSuite", test.m_details.suiteName);
+}
+
+TEST (TestReflectsSpecifiedSuiteName)
+{
+    Test test("test", "testSuite");
+    CHECK(test.m_details.suiteName != NULL);
+    CHECK_EQUAL("testSuite", test.m_details.suiteName);
+}
+
+
+}