summaryrefslogtreecommitdiff
path: root/unittests/LinearAllocatorTest.h
blob: a6be2b78d0fc1f004211395f02538b4d4928f344 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//===- LinearAllocatorTest.h ----------------------------------------------===//
//
//                     The MCLinker Project
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#ifndef LINEAR_ALLOCATOR_TEST_H
#define LINEAR_ALLOCATOR_TEST_H

#include <gtest.h>
#include "mcld/Support/Allocators.h"

namespace mcldtest
{

/** \class LinearAllocatorTest
 *  \brief The testcase for LinearAllocator
 *
 *  \see LinearAllocator 
 */
class LinearAllocatorTest : public ::testing::Test
{
public:
	struct Data {
		Data()
		: one(1), two(2), three(3), four(4)
		{ }

		Data( unsigned int pOne, unsigned int pTwo, unsigned char pThree, unsigned char pFour)
		{
			one = pOne;
			two = pTwo;
			three = pThree;
			four = pFour;
		}

		~Data()
		{
			one = -1;
			two = -2;
			three = -3;
			four = -4;
		}

		unsigned int one;
		unsigned int two;
		unsigned char three;
		unsigned char four;
	};
public:
	// Constructor can do set-up work for all test here.
	LinearAllocatorTest();

	// Destructor can do clean-up work that doesn't throw exceptions here.
	virtual ~LinearAllocatorTest();

	// SetUp() will be called immediately before each test.
	virtual void SetUp();

	// TearDown() will be called immediately after each test.
	virtual void TearDown();

protected:
	enum TemplateArgsType { CHUNK_SIZE = 32 };
	typedef mcld::LinearAllocator<Data, CHUNK_SIZE> Alloc;
protected:
	Alloc* m_pTestee;
};

} // namespace of mcldtest

#endif