1 //===- LinearAllocatorTest.h ----------------------------------------------===// 2 // 3 // The MCLinker Project 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 #ifndef LINEAR_ALLOCATOR_TEST_H 10 #define LINEAR_ALLOCATOR_TEST_H 11 12 #include <gtest.h> 13 #include "mcld/Support/Allocators.h" 14 15 namespace mcldtest { 16 17 /** \class LinearAllocatorTest 18 * \brief The testcase for LinearAllocator 19 * 20 * \see LinearAllocator 21 */ 22 class LinearAllocatorTest : public ::testing::Test { 23 public: 24 struct Data { DataData25 Data() : one(1), two(2), three(3), four(4) {} 26 DataData27 Data(unsigned int pOne, 28 unsigned int pTwo, 29 unsigned char pThree, 30 unsigned char pFour) { 31 one = pOne; 32 two = pTwo; 33 three = pThree; 34 four = pFour; 35 } 36 ~DataData37 ~Data() { 38 one = -1; 39 two = -2; 40 three = -3; 41 four = -4; 42 } 43 44 unsigned int one; 45 unsigned int two; 46 unsigned char three; 47 unsigned char four; 48 }; 49 50 public: 51 // Constructor can do set-up work for all test here. 52 LinearAllocatorTest(); 53 54 // Destructor can do clean-up work that doesn't throw exceptions here. 55 virtual ~LinearAllocatorTest(); 56 57 // SetUp() will be called immediately before each test. 58 virtual void SetUp(); 59 60 // TearDown() will be called immediately after each test. 61 virtual void TearDown(); 62 63 protected: 64 enum TemplateArgsType { CHUNK_SIZE = 32 }; 65 typedef mcld::LinearAllocator<Data, CHUNK_SIZE> Alloc; 66 67 protected: 68 Alloc* m_pTestee; 69 }; 70 71 } // namespace of mcldtest 72 73 #endif 74