Mercurial > fife-parpg
view ext/UnitTest++/src/tests/TestTestResults.cpp @ 342:7be6293f13d1
Made LayerEditor prettier
author | cheesesucker@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Tue, 25 Aug 2009 00:31:16 +0000 |
parents | 0d325e9d5953 |
children |
line wrap: on
line source
#include "../UnitTest++.h" #include "../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); } }