Changeset 118:60d762efb225 in rrlib_util


Ignore:
Timestamp:
05.06.2014 12:18:17 (5 years ago)
Author:
Tobias Föhst <foehst@…>
Branch:
default
Phase:
public
Message:

Added default implementation for tUnitTestSuite's InitializeTests and CleanUp methods as they are not used in most cases

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • tUnitTestSuite.cpp

    r98 r118  
    7474 
    7575//---------------------------------------------------------------------- 
     76// tUnitTestSuite destructor 
     77//---------------------------------------------------------------------- 
     78tUnitTestSuite::~tUnitTestSuite() 
     79{} 
     80 
     81//---------------------------------------------------------------------- 
    7682// tUnitTestSuite setUp 
    7783//---------------------------------------------------------------------- 
  • tUnitTestSuite.h

    r116 r118  
    8686public: 
    8787 
     88  ~tUnitTestSuite() = 0; 
     89 
    8890  void setUp(); 
    8991 
     
    9294private: 
    9395 
    94   virtual void InitializeTests() = 0; 
     96  virtual void InitializeTests() 
     97  {}; 
    9598 
    96   virtual void CleanUp() = 0; 
     99  virtual void CleanUp() 
     100  {}; 
    97101 
    98102}; 
  • tests/string.cpp

    r115 r118  
    7070//---------------------------------------------------------------------- 
    7171 
    72 class tTestString : public rrlib::util::tUnitTestSuite 
     72class TestString : public util::tUnitTestSuite 
    7373{ 
    74   RRLIB_UNIT_TESTS_BEGIN_SUITE(tTestString); 
     74  RRLIB_UNIT_TESTS_BEGIN_SUITE(TestString); 
    7575  RRLIB_UNIT_TESTS_ADD_TEST(TestFunctions); 
    7676  RRLIB_UNIT_TESTS_END_SUITE; 
    7777 
    7878private: 
    79  
    80   virtual void InitializeTests() {} 
    81   virtual void CleanUp() {} 
    8279 
    8380  virtual void TestFunctions() 
     
    138135}; 
    139136 
    140 RRLIB_UNIT_TESTS_REGISTER_SUITE(tTestString); 
     137RRLIB_UNIT_TESTS_REGISTER_SUITE(TestString); 
    141138 
    142139//---------------------------------------------------------------------- 
  • tests/tagged_pointer.cpp

    r115 r118  
    7373// Implementation 
    7474//---------------------------------------------------------------------- 
    75 class tTestTaggedPointer : public util::tUnitTestSuite 
     75class TestTaggedPointer : public util::tUnitTestSuite 
    7676{ 
    77   RRLIB_UNIT_TESTS_BEGIN_SUITE(tTestTaggedPointer); 
     77  RRLIB_UNIT_TESTS_BEGIN_SUITE(TestTaggedPointer); 
    7878  RRLIB_UNIT_TESTS_ADD_TEST(RunAllTests); 
    7979  RRLIB_UNIT_TESTS_END_SUITE; 
     
    8484  std::mt19937 engine; 
    8585 
    86   virtual void InitializeTests() 
     86  virtual void InitializeTests() override 
    8787  { 
    8888    this->engine = std::mt19937(1234); 
    8989  } 
    9090 
    91   virtual void CleanUp() 
    92   {} 
    93  
    9491  template <typename T, bool ALIGNED_POINTERS, uint TAG_BIT_WIDTH> 
    95   void TestTaggedPointer() 
     92  void RunTests() 
    9693  { 
    9794    // Some variables of type T 
     
    111108    // Test all methods 
    112109    pointer.Set(&array[7], 1); 
    113     assert(pointer.GetPointer() == &array[7] && pointer.GetStamp() == 1); 
     110    RRLIB_UNIT_TESTS_ASSERT(pointer.GetPointer() == &array[7] && pointer.GetStamp() == 1); 
    114111    pointer.SetPointer(&single_value); 
    115     assert(pointer.GetPointer() == &single_value && pointer.GetStamp() == 1); 
     112    RRLIB_UNIT_TESTS_ASSERT(pointer.GetPointer() == &single_value && pointer.GetStamp() == 1); 
    116113    pointer.SetStamp(0xCAFE7 & tPointer::cSTAMP_MASK); 
    117     assert(pointer.GetPointer() == &single_value && pointer.GetStamp() == (0xCAFE7 & tPointer::cSTAMP_MASK)); 
     114    RRLIB_UNIT_TESTS_ASSERT(pointer.GetPointer() == &single_value && pointer.GetStamp() == (0xCAFE7 & tPointer::cSTAMP_MASK)); 
    118115 
    119116    // Test operators 
     
    124121    atomic_storage = pointer; 
    125122    pointer = atomic_storage + 1; 
    126     assert(pointer.GetPointer() == &single_value && pointer.GetStamp() == (0xCAFE7 & tPointer::cSTAMP_MASK)); 
     123    RRLIB_UNIT_TESTS_ASSERT(pointer.GetPointer() == &single_value && pointer.GetStamp() == (0xCAFE7 & tPointer::cSTAMP_MASK)); 
    127124 
    128125    // Test with allocated values and random stamp 
     
    132129      uint random = uniform_int_distribution(this->engine) & tPointer::cSTAMP_MASK; 
    133130      pointer.Set(allocated_values[idx].get(), random); 
    134       assert(pointer.GetPointer() == allocated_values[idx].get() && pointer.GetStamp() == random); 
     131      RRLIB_UNIT_TESTS_ASSERT(pointer.GetPointer() == allocated_values[idx].get() && pointer.GetStamp() == random); 
    135132      random = uniform_int_distribution(this->engine) & tPointer::cSTAMP_MASK; 
    136133      pointer.SetPointer(&array[idx]); 
    137134      pointer.SetStamp(random); 
    138       assert(pointer.GetPointer() == &array[idx] && pointer.GetStamp() == random); 
     135      RRLIB_UNIT_TESTS_ASSERT(pointer.GetPointer() == &array[idx] && pointer.GetStamp() == random); 
    139136    } 
    140137  } 
     
    147144    }; 
    148145 
    149     TestTaggedPointer<tTestType, true, 1>(); 
    150     TestTaggedPointer<tTestType, true, 2>(); 
    151     TestTaggedPointer<tTestType, true, 3>(); 
    152     TestTaggedPointer<tTestType, true, 4>(); 
    153     TestTaggedPointer<tTestType, true, 5>(); 
    154     TestTaggedPointer<tTestType, true, 6>(); 
    155     TestTaggedPointer<tTestType, true, 7>(); 
    156     TestTaggedPointer<tTestType, true, 8>(); 
    157     TestTaggedPointer<tTestType, true, 9>(); 
    158     TestTaggedPointer<tTestType, true, 10>(); 
    159     TestTaggedPointer<tTestType, true, 11>(); 
    160     TestTaggedPointer<tTestType, true, 12>(); 
    161     TestTaggedPointer<tTestType, true, 13>(); 
    162     TestTaggedPointer<tTestType, true, 14>(); 
    163     TestTaggedPointer<tTestType, true, 15>(); 
    164     TestTaggedPointer<tTestType, true, 16>(); 
    165     TestTaggedPointer<tTestType, true, 17>(); 
    166     TestTaggedPointer<tTestType, true, 18>(); 
    167     TestTaggedPointer<tTestType, true, 19>(); 
    168     TestTaggedPointer<int16_t, false, 1>(); 
    169     TestTaggedPointer<int16_t, false, 2>(); 
    170     TestTaggedPointer<int16_t, false, 3>(); 
    171     TestTaggedPointer<int16_t, false, 4>(); 
    172     TestTaggedPointer<int16_t, false, 5>(); 
    173     TestTaggedPointer<int16_t, false, 6>(); 
    174     TestTaggedPointer<int16_t, false, 7>(); 
    175     TestTaggedPointer<int16_t, false, 8>(); 
    176     TestTaggedPointer<int16_t, false, 9>(); 
    177     TestTaggedPointer<int16_t, false, 10>(); 
    178     TestTaggedPointer<int16_t, false, 11>(); 
    179     TestTaggedPointer<int16_t, false, 12>(); 
    180     TestTaggedPointer<int16_t, false, 13>(); 
    181     TestTaggedPointer<int16_t, false, 14>(); 
    182     TestTaggedPointer<int16_t, false, 15>(); 
    183     TestTaggedPointer<int16_t, false, 16>(); 
     146    RunTests<tTestType, true, 1>(); 
     147    RunTests<tTestType, true, 2>(); 
     148    RunTests<tTestType, true, 3>(); 
     149    RunTests<tTestType, true, 4>(); 
     150    RunTests<tTestType, true, 5>(); 
     151    RunTests<tTestType, true, 6>(); 
     152    RunTests<tTestType, true, 7>(); 
     153    RunTests<tTestType, true, 8>(); 
     154    RunTests<tTestType, true, 9>(); 
     155    RunTests<tTestType, true, 10>(); 
     156    RunTests<tTestType, true, 11>(); 
     157    RunTests<tTestType, true, 12>(); 
     158    RunTests<tTestType, true, 13>(); 
     159    RunTests<tTestType, true, 14>(); 
     160    RunTests<tTestType, true, 15>(); 
     161    RunTests<tTestType, true, 16>(); 
     162    RunTests<tTestType, true, 17>(); 
     163    RunTests<tTestType, true, 18>(); 
     164    RunTests<tTestType, true, 19>(); 
     165    RunTests<int16_t, false, 1>(); 
     166    RunTests<int16_t, false, 2>(); 
     167    RunTests<int16_t, false, 3>(); 
     168    RunTests<int16_t, false, 4>(); 
     169    RunTests<int16_t, false, 5>(); 
     170    RunTests<int16_t, false, 6>(); 
     171    RunTests<int16_t, false, 7>(); 
     172    RunTests<int16_t, false, 8>(); 
     173    RunTests<int16_t, false, 9>(); 
     174    RunTests<int16_t, false, 10>(); 
     175    RunTests<int16_t, false, 11>(); 
     176    RunTests<int16_t, false, 12>(); 
     177    RunTests<int16_t, false, 13>(); 
     178    RunTests<int16_t, false, 14>(); 
     179    RunTests<int16_t, false, 15>(); 
     180    RunTests<int16_t, false, 16>(); 
    184181  } 
    185182}; 
    186183 
    187 RRLIB_UNIT_TESTS_REGISTER_SUITE(tTestTaggedPointer); 
     184RRLIB_UNIT_TESTS_REGISTER_SUITE(TestTaggedPointer); 
    188185 
    189186//---------------------------------------------------------------------- 
  • tests/type_list.cpp

    r115 r118  
    7070// Implementation 
    7171//---------------------------------------------------------------------- 
    72 class tTestTypeList : public util::tUnitTestSuite 
     72class TestTypeList : public util::tUnitTestSuite 
    7373{ 
    74   RRLIB_UNIT_TESTS_BEGIN_SUITE(tTestTypeList); 
     74  RRLIB_UNIT_TESTS_BEGIN_SUITE(TestTypeList); 
    7575  RRLIB_UNIT_TESTS_ADD_TEST(Size); 
    7676  RRLIB_UNIT_TESTS_ADD_TEST(At); 
     
    9090 
    9191  typedef tTypeList<A, C, B, C, D> tList; 
    92  
    93   virtual void InitializeTests() 
    94   {} 
    95  
    96   virtual void CleanUp() 
    97   {} 
    9892 
    9993  void Size() 
     
    168162}; 
    169163 
    170 RRLIB_UNIT_TESTS_REGISTER_SUITE(tTestTypeList); 
     164RRLIB_UNIT_TESTS_REGISTER_SUITE(TestTypeList); 
    171165 
    172166//---------------------------------------------------------------------- 
Note: See TracChangeset for help on using the changeset viewer.