?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download

  1. #include "UnitTest++/UnitTestPP.h"
  2. #include "UnitTest++/TestResults.h"
  3. #include "UnitTest++/TimeHelpers.h"
  4. #include "RecordingReporter.h"
  5. #include "ScopedCurrentTest.h"
  6.  
  7. using namespace UnitTest;
  8.  
  9. namespace
  10. {
  11.  
  12.    TEST(TimeConstraintSucceedsWithFastTest)
  13.    {
  14.       TestResults result;
  15.       {
  16.          ScopedCurrentTest scopedResult(result);
  17.          TimeConstraint t(200, TestDetails("", "", "", 0), 0);
  18.          TimeHelpers::SleepMs(5);
  19.       }
  20.       CHECK_EQUAL(0, result.GetFailureCount());
  21.    }
  22.  
  23.    TEST(TimeConstraintFailsWithSlowTest)
  24.    {
  25.       TestResults result;
  26.       {
  27.          ScopedCurrentTest scopedResult(result);
  28.          TimeConstraint t(10, TestDetails("", "", "", 0),0);
  29.          TimeHelpers::SleepMs(20);
  30.       }
  31.       CHECK_EQUAL(1, result.GetFailureCount());
  32.    }
  33.  
  34.    TEST(TimeConstraintFailureIncludesCorrectData)
  35.    {
  36.       RecordingReporter reporter;
  37.       TestResults result(&reporter);
  38.       {
  39.          ScopedCurrentTest scopedResult(result);
  40.  
  41.          TestDetails const details("testname", "suitename", "filename", 10);
  42.          TimeConstraint t(10, details,10);
  43.          TimeHelpers::SleepMs(20);
  44.       }
  45.  
  46.       using namespace std;
  47.  
  48.       CHECK(strstr(reporter.lastFailedFile, "filename"));
  49.       CHECK_EQUAL(10, reporter.lastFailedLine);
  50.       CHECK(strstr(reporter.lastFailedTest, "testname"));
  51.    }
  52.  
  53.    TEST(TimeConstraintFailureIncludesTimeoutInformation)
  54.    {
  55.       RecordingReporter reporter;
  56.       TestResults result(&reporter);
  57.       {
  58.          ScopedCurrentTest scopedResult(result);
  59.          TimeConstraint t(10, TestDetails("", "", "", 0),0);
  60.          TimeHelpers::SleepMs(20);
  61.       }
  62.  
  63.       using namespace std;
  64.  
  65.       CHECK(strstr(reporter.lastFailedMessage, "ime constraint"));
  66.       CHECK(strstr(reporter.lastFailedMessage, "under 10ms"));
  67.    }
  68.  
  69. }
  70.