blob: fd9db106e7afb9e4a3892f0228ce31ac8e4ac073 [file] [log] [blame]
Shih-wei Liao5460a1f2012-03-16 22:41:16 -07001//===- 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
Stephen Hines37b74a32014-11-26 18:48:20 -080015namespace mcldtest {
Shih-wei Liao5460a1f2012-03-16 22:41:16 -070016
17/** \class LinearAllocatorTest
18 * \brief The testcase for LinearAllocator
19 *
Stephen Hines551ae4e2014-04-24 14:41:24 -070020 * \see LinearAllocator
Shih-wei Liao5460a1f2012-03-16 22:41:16 -070021 */
Stephen Hines37b74a32014-11-26 18:48:20 -080022class LinearAllocatorTest : public ::testing::Test {
23 public:
24 struct Data {
25 Data() : one(1), two(2), three(3), four(4) {}
Shih-wei Liao5460a1f2012-03-16 22:41:16 -070026
Stephen Hines37b74a32014-11-26 18:48:20 -080027 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 }
Shih-wei Liao5460a1f2012-03-16 22:41:16 -070036
Stephen Hines37b74a32014-11-26 18:48:20 -080037 ~Data() {
38 one = -1;
39 two = -2;
40 three = -3;
41 four = -4;
42 }
Shih-wei Liao5460a1f2012-03-16 22:41:16 -070043
Stephen Hines37b74a32014-11-26 18:48:20 -080044 unsigned int one;
45 unsigned int two;
46 unsigned char three;
47 unsigned char four;
48 };
Shih-wei Liao5460a1f2012-03-16 22:41:16 -070049
Stephen Hines37b74a32014-11-26 18:48:20 -080050 public:
51 // Constructor can do set-up work for all test here.
52 LinearAllocatorTest();
Shih-wei Liao5460a1f2012-03-16 22:41:16 -070053
Stephen Hines37b74a32014-11-26 18:48:20 -080054 // Destructor can do clean-up work that doesn't throw exceptions here.
55 virtual ~LinearAllocatorTest();
Shih-wei Liao5460a1f2012-03-16 22:41:16 -070056
Stephen Hines37b74a32014-11-26 18:48:20 -080057 // SetUp() will be called immediately before each test.
58 virtual void SetUp();
Shih-wei Liao5460a1f2012-03-16 22:41:16 -070059
Stephen Hines37b74a32014-11-26 18:48:20 -080060 // 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;
Shih-wei Liao5460a1f2012-03-16 22:41:16 -070069};
70
Stephen Hines37b74a32014-11-26 18:48:20 -080071} // namespace of mcldtest
Shih-wei Liao5460a1f2012-03-16 22:41:16 -070072
73#endif