blob: 2c4a732885bb9134beaf30d082331f8538f286f0 [file] [log] [blame]
Shih-wei Liao5460a1f2012-03-16 22:41:16 -07001//===- RTLinearAllocatorTest.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 RTLINEARALLOCATOR_TEST_H
10#define RTLINEARALLOCATOR_TEST_H
11
12#include <gtest.h>
13#include "mcld/Support/Allocators.h"
14
Stephen Hines37b74a32014-11-26 18:48:20 -080015namespace mcldtest {
Shih-wei Liao5460a1f2012-03-16 22:41:16 -070016
17/** \class RTLinearAllocatorTest
Stephen Hines551ae4e2014-04-24 14:41:24 -070018 * \brief
Shih-wei Liao5460a1f2012-03-16 22:41:16 -070019 *
Stephen Hines551ae4e2014-04-24 14:41:24 -070020 * \see RTLinearAllocator
Shih-wei Liao5460a1f2012-03-16 22:41:16 -070021 */
Stephen Hines37b74a32014-11-26 18:48:20 -080022class RTLinearAllocatorTest : public ::testing::Test {
23 public:
24 // Constructor can do set-up work for all test here.
25 RTLinearAllocatorTest();
Shih-wei Liao5460a1f2012-03-16 22:41:16 -070026
Stephen Hines37b74a32014-11-26 18:48:20 -080027 // Destructor can do clean-up work that doesn't throw exceptions here.
28 virtual ~RTLinearAllocatorTest();
Shih-wei Liao5460a1f2012-03-16 22:41:16 -070029
Stephen Hines37b74a32014-11-26 18:48:20 -080030 // SetUp() will be called immediately before each test.
31 virtual void SetUp();
Shih-wei Liao5460a1f2012-03-16 22:41:16 -070032
Stephen Hines37b74a32014-11-26 18:48:20 -080033 // TearDown() will be called immediately after each test.
34 virtual void TearDown();
Shih-wei Liao5460a1f2012-03-16 22:41:16 -070035
Stephen Hines37b74a32014-11-26 18:48:20 -080036 public:
37 struct Data {
38 Data() : one(1), two(2), three(3), four(4) {}
Shih-wei Liao5460a1f2012-03-16 22:41:16 -070039
Stephen Hines37b74a32014-11-26 18:48:20 -080040 Data(unsigned int pOne,
41 unsigned int pTwo,
42 unsigned char pThree,
43 unsigned char pFour) {
44 one = pOne;
45 two = pTwo;
46 three = pThree;
47 four = pFour;
48 }
Shih-wei Liao5460a1f2012-03-16 22:41:16 -070049
Stephen Hines37b74a32014-11-26 18:48:20 -080050 ~Data() {
51 one = -1;
52 two = -2;
53 three = -3;
54 four = -4;
55 }
Shih-wei Liao5460a1f2012-03-16 22:41:16 -070056
Stephen Hines37b74a32014-11-26 18:48:20 -080057 unsigned int one;
58 unsigned int two;
59 unsigned char three;
60 unsigned char four;
Shih-wei Liao5460a1f2012-03-16 22:41:16 -070061 };
Stephen Hines37b74a32014-11-26 18:48:20 -080062 enum { CHUNK_SIZE = 32 };
Shih-wei Liao5460a1f2012-03-16 22:41:16 -070063
Stephen Hines37b74a32014-11-26 18:48:20 -080064 protected:
65 mcld::LinearAllocator<Data, 0>* m_pTestee;
Shih-wei Liao5460a1f2012-03-16 22:41:16 -070066};
67
Stephen Hines37b74a32014-11-26 18:48:20 -080068} // namespace of mcldtest
Shih-wei Liao5460a1f2012-03-16 22:41:16 -070069
70#endif