?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. #include "TimeConstraint.h"
  2. #include "TestResults.h"
  3. #include "MemoryOutStream.h"
  4. #include "CurrentTest.h"
  5.  
  6. namespace UnitTest {
  7.  
  8.  
  9.    TimeConstraint::TimeConstraint(int ms, TestDetails const& details, int lineNumber)
  10.       : m_details(details, lineNumber)
  11.       , m_maxMs(ms)
  12.    {
  13.       m_timer.Start();
  14.    }
  15.  
  16.    TimeConstraint::~TimeConstraint()
  17.    {
  18.       double const totalTimeInMs = m_timer.GetTimeInMs();
  19.       if (totalTimeInMs > m_maxMs)
  20.       {
  21.          MemoryOutStream stream;
  22.          stream << "Time constraint failed. Expected to run test under " << m_maxMs <<
  23.             "ms but took " << totalTimeInMs << "ms.";
  24.  
  25.          CurrentTest::Results()->OnTestFailure(m_details, stream.GetText());
  26.       }
  27.    }
  28.  
  29. }
  30.