?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download

  1. #include "UnitTest++/UnitTestPP.h"
  2. #include "UnitTest++/TestResults.h"
  3. #include "RecordingReporter.h"
  4.  
  5. using namespace UnitTest;
  6.  
  7. namespace {
  8.  
  9.    TestDetails const details("testname", "suitename", "filename", 123);
  10.  
  11.  
  12.    TEST(StartsWithNoTestsRun)
  13.    {
  14.       TestResults results;
  15.       CHECK_EQUAL (0, results.GetTotalTestCount());
  16.    }
  17.  
  18.    TEST(RecordsNumbersOfTests)
  19.    {
  20.       TestResults results;
  21.       results.OnTestStart(details);
  22.       results.OnTestStart(details);
  23.       results.OnTestStart(details);
  24.       CHECK_EQUAL(3, results.GetTotalTestCount());
  25.    }
  26.  
  27.    TEST(StartsWithNoTestsFailing)
  28.    {
  29.       TestResults results;
  30.       CHECK_EQUAL (0, results.GetFailureCount());
  31.    }
  32.  
  33.    TEST(RecordsNumberOfFailures)
  34.    {
  35.       TestResults results;
  36.       results.OnTestFailure(details, "");
  37.       results.OnTestFailure(details, "");
  38.       CHECK_EQUAL(2, results.GetFailureCount());
  39.    }
  40.  
  41.    TEST(RecordsNumberOfFailedTests)
  42.    {
  43.       TestResults results;
  44.  
  45.       results.OnTestStart(details);
  46.       results.OnTestFailure(details, "");
  47.       results.OnTestFinish(details, 0);
  48.  
  49.       results.OnTestStart(details);
  50.       results.OnTestFailure(details, "");
  51.       results.OnTestFailure(details, "");
  52.       results.OnTestFailure(details, "");
  53.       results.OnTestFinish(details, 0);
  54.  
  55.       CHECK_EQUAL (2, results.GetFailedTestCount());
  56.    }
  57.  
  58.    TEST(NotifiesReporterOfTestStartWithCorrectInfo)
  59.    {
  60.       RecordingReporter reporter;
  61.       TestResults results(&reporter);
  62.       results.OnTestStart(details);
  63.  
  64.       CHECK_EQUAL (1, reporter.testRunCount);
  65.       CHECK_EQUAL ("suitename", reporter.lastStartedSuite);
  66.       CHECK_EQUAL ("testname", reporter.lastStartedTest);
  67.    }
  68.  
  69.    TEST(NotifiesReporterOfTestFailureWithCorrectInfo)
  70.    {
  71.       RecordingReporter reporter;
  72.       TestResults results(&reporter);
  73.  
  74.       results.OnTestFailure(details, "failurestring");
  75.       CHECK_EQUAL (1, reporter.testFailedCount);
  76.       CHECK_EQUAL ("filename", reporter.lastFailedFile);
  77.       CHECK_EQUAL (123, reporter.lastFailedLine);
  78.       CHECK_EQUAL ("suitename", reporter.lastFailedSuite);
  79.       CHECK_EQUAL ("testname", reporter.lastFailedTest);
  80.       CHECK_EQUAL ("failurestring", reporter.lastFailedMessage);
  81.    }
  82.  
  83.    TEST(NotifiesReporterOfCheckFailureWithCorrectInfo)
  84.    {
  85.       RecordingReporter reporter;
  86.       TestResults results(&reporter);
  87.  
  88.       results.OnTestFailure(details, "failurestring");
  89.       CHECK_EQUAL (1, reporter.testFailedCount);
  90.  
  91.       CHECK_EQUAL ("filename", reporter.lastFailedFile);
  92.       CHECK_EQUAL (123, reporter.lastFailedLine);
  93.       CHECK_EQUAL ("testname", reporter.lastFailedTest);
  94.       CHECK_EQUAL ("suitename", reporter.lastFailedSuite);
  95.       CHECK_EQUAL ("failurestring", reporter.lastFailedMessage);
  96.    }
  97.  
  98.    TEST(NotifiesReporterOfTestEnd)
  99.    {
  100.       RecordingReporter reporter;
  101.       TestResults results(&reporter);
  102.  
  103.       results.OnTestFinish(details, 0.1234f);
  104.       CHECK_EQUAL (1, reporter.testFinishedCount);
  105.       CHECK_EQUAL ("testname", reporter.lastFinishedTest);
  106.       CHECK_EQUAL ("suitename", reporter.lastFinishedSuite);
  107.       CHECK_CLOSE (0.1234f, reporter.lastFinishedTestTime, 0.0001f);
  108.    }
  109.  
  110.  
  111. }
  112.