hayai_test.hpp
Go to the documentation of this file.
00001 #ifndef __HAYAI_TEST
00002 #define __HAYAI_TEST
00003 #include <cstddef>
00004 
00005 #include "hayai/hayai_clock.hpp"
00006 #include "hayai/hayai_test_result.hpp"
00007 
00008 
00009 namespace hayai
00010 {
00012 
00020     class Test
00021     {
00022     public:
00024         virtual void SetUp()
00025         {
00026 
00027         }
00028 
00029 
00032         virtual void TearDown()
00033         {
00034 
00035         }
00036 
00037 
00039 
00042         uint64_t Run(std::size_t iterations)
00043         {
00044             std::size_t iteration = iterations;
00045 
00046             // Set up the testing fixture.
00047             SetUp();
00048 
00049             // Get the starting time.
00050             Clock::TimePoint startTime, endTime;
00051 
00052             startTime = Clock::Now();
00053 
00054             // Run the test body for each iteration.
00055             while (iteration--)
00056             {
00057                 TestBody();
00058             }
00059 
00060             // Get the ending time.
00061             endTime = Clock::Now();
00062 
00063             // Tear down the testing fixture.
00064             TearDown();
00065 
00066             // Return the duration in nanoseconds.
00067             return Clock::Duration(startTime, endTime);
00068         }
00069 
00070 
00071         virtual ~Test()
00072         {
00073 
00074         }
00075     protected:
00077 
00079         virtual void TestBody()
00080         {
00081 
00082         }
00083     };
00084 }
00085 #endif


hayai
Author(s): Nick Bruun
autogenerated on Thu Jun 6 2019 18:13:43