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
15namespace mcldtest
16{
17
18/** \class LinearAllocatorTest
19 *  \brief The testcase for LinearAllocator
20 *
21 *  \see LinearAllocator
22 */
23class LinearAllocatorTest : public ::testing::Test
24{
25public:
26	struct Data {
27		Data()
28		: one(1), two(2), three(3), four(4)
29		{ }
30
31		Data( unsigned int pOne, unsigned int pTwo, unsigned char pThree, unsigned char pFour)
32		{
33			one = pOne;
34			two = pTwo;
35			three = pThree;
36			four = pFour;
37		}
38
39		~Data()
40		{
41			one = -1;
42			two = -2;
43			three = -3;
44			four = -4;
45		}
46
47		unsigned int one;
48		unsigned int two;
49		unsigned char three;
50		unsigned char four;
51	};
52public:
53	// Constructor can do set-up work for all test here.
54	LinearAllocatorTest();
55
56	// Destructor can do clean-up work that doesn't throw exceptions here.
57	virtual ~LinearAllocatorTest();
58
59	// SetUp() will be called immediately before each test.
60	virtual void SetUp();
61
62	// TearDown() will be called immediately after each test.
63	virtual void TearDown();
64
65protected:
66	enum { CHUNK_SIZE = 32 };
67	typedef mcld::LinearAllocator<Data, CHUNK_SIZE> Alloc;
68protected:
69	Alloc* m_pTestee;
70};
71
72} // namespace of mcldtest
73
74#endif
75
76