summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/unittest-cpp/tests/TestTestResults.cpp
diff options
context:
space:
mode:
author Miodrag Milanovic <mmicko@gmail.com>2015-05-27 15:00:06 +0200
committer Miodrag Milanovic <mmicko@gmail.com>2015-05-27 15:00:06 +0200
commitee4adf600bdd3aa60cc0e92a39f2111be0a90bc6 (patch)
tree5ecb86b72eef1c19ad3ab6c7ba8d8b2a964e0cb9 /3rdparty/unittest-cpp/tests/TestTestResults.cpp
parent55fa9840f263361efc73126c3f41be606fea7168 (diff)
Added library for supporting unit tests (nw)
Diffstat (limited to '3rdparty/unittest-cpp/tests/TestTestResults.cpp')
-rw-r--r--3rdparty/unittest-cpp/tests/TestTestResults.cpp111
1 files changed, 111 insertions, 0 deletions
diff --git a/3rdparty/unittest-cpp/tests/TestTestResults.cpp b/3rdparty/unittest-cpp/tests/TestTestResults.cpp
new file mode 100644
index 00000000000..a1156874676
--- /dev/null
+++ b/3rdparty/unittest-cpp/tests/TestTestResults.cpp
@@ -0,0 +1,111 @@
+#include "UnitTest++/UnitTestPP.h"
+#include "UnitTest++/TestResults.h"
+#include "RecordingReporter.h"
+
+using namespace UnitTest;
+
+namespace {
+
+TestDetails const details("testname", "suitename", "filename", 123);
+
+
+TEST(StartsWithNoTestsRun)
+{
+ TestResults results;
+ CHECK_EQUAL (0, results.GetTotalTestCount());
+}
+
+TEST(RecordsNumbersOfTests)
+{
+ TestResults results;
+ results.OnTestStart(details);
+ results.OnTestStart(details);
+ results.OnTestStart(details);
+ CHECK_EQUAL(3, results.GetTotalTestCount());
+}
+
+TEST(StartsWithNoTestsFailing)
+{
+ TestResults results;
+ CHECK_EQUAL (0, results.GetFailureCount());
+}
+
+TEST(RecordsNumberOfFailures)
+{
+ TestResults results;
+ results.OnTestFailure(details, "");
+ results.OnTestFailure(details, "");
+ CHECK_EQUAL(2, results.GetFailureCount());
+}
+
+TEST(RecordsNumberOfFailedTests)
+{
+ TestResults results;
+
+ results.OnTestStart(details);
+ results.OnTestFailure(details, "");
+ results.OnTestFinish(details, 0);
+
+ results.OnTestStart(details);
+ results.OnTestFailure(details, "");
+ results.OnTestFailure(details, "");
+ results.OnTestFailure(details, "");
+ results.OnTestFinish(details, 0);
+
+ CHECK_EQUAL (2, results.GetFailedTestCount());
+}
+
+TEST(NotifiesReporterOfTestStartWithCorrectInfo)
+{
+ RecordingReporter reporter;
+ TestResults results(&reporter);
+ results.OnTestStart(details);
+
+ CHECK_EQUAL (1, reporter.testRunCount);
+ CHECK_EQUAL ("suitename", reporter.lastStartedSuite);
+ CHECK_EQUAL ("testname", reporter.lastStartedTest);
+}
+
+TEST(NotifiesReporterOfTestFailureWithCorrectInfo)
+{
+ RecordingReporter reporter;
+ TestResults results(&reporter);
+
+ results.OnTestFailure(details, "failurestring");
+ CHECK_EQUAL (1, reporter.testFailedCount);
+ CHECK_EQUAL ("filename", reporter.lastFailedFile);
+ CHECK_EQUAL (123, reporter.lastFailedLine);
+ CHECK_EQUAL ("suitename", reporter.lastFailedSuite);
+ CHECK_EQUAL ("testname", reporter.lastFailedTest);
+ CHECK_EQUAL ("failurestring", reporter.lastFailedMessage);
+}
+
+TEST(NotifiesReporterOfCheckFailureWithCorrectInfo)
+{
+ RecordingReporter reporter;
+ TestResults results(&reporter);
+
+ results.OnTestFailure(details, "failurestring");
+ CHECK_EQUAL (1, reporter.testFailedCount);
+
+ CHECK_EQUAL ("filename", reporter.lastFailedFile);
+ CHECK_EQUAL (123, reporter.lastFailedLine);
+ CHECK_EQUAL ("testname", reporter.lastFailedTest);
+ CHECK_EQUAL ("suitename", reporter.lastFailedSuite);
+ CHECK_EQUAL ("failurestring", reporter.lastFailedMessage);
+}
+
+TEST(NotifiesReporterOfTestEnd)
+{
+ RecordingReporter reporter;
+ TestResults results(&reporter);
+
+ results.OnTestFinish(details, 0.1234f);
+ CHECK_EQUAL (1, reporter.testFinishedCount);
+ CHECK_EQUAL ("testname", reporter.lastFinishedTest);
+ CHECK_EQUAL ("suitename", reporter.lastFinishedSuite);
+ CHECK_CLOSE (0.1234f, reporter.lastFinishedTestTime, 0.0001f);
+}
+
+
+}