remove \r
[extl.git] / extl / win / memory / unit_test / virtual_allocator_test.h
blob7eced26557dc7291a5cd28adbfd66470a934309d
1 /* ///////////////////////////////////////////////////////////////////////
2 * File: virtual_allocator_test.h
4 * Created: 08.02.20
5 * Updated: 08.05.06
7 * Brief: Unit-testing
9 * [<Home>]
10 * Copyright (c) 2008-2020, Waruqi All rights reserved.
11 * //////////////////////////////////////////////////////////////////// */
12 #ifndef EXTL_MEMORY_VIRTUAL_ALLOCATOR_TEST_H
13 #define EXTL_MEMORY_VIRTUAL_ALLOCATOR_TEST_H
15 #ifndef EXTL_PLATFORM_WIN_MEMORY_VIRTUAL_ALLOCATOR_H
16 # error This file must be included of virtual_allocator.h
17 #endif
19 /* ///////////////////////////////////////////////////////////////////////
20 * ::unit_test namespace
22 EXTL_TEST_BEGIN_NAMESPACE
24 /* ///////////////////////////////////////////////////////////////////////
25 * Unit-testing
27 #ifdef EXTL_TEMPLATE_CLASS_DEFAULT_ARGUMENT_SUPPORT
28 template < typename_param_k T, typename_param_k A = virtual_allocator<T> >
29 #else
30 template < typename_param_k T, typename_param_k A >
31 #endif
32 struct virtual_allocator_test
34 virtual_allocator_test()
36 virtual_allocator<void> void_allocator;
38 A allocator;
39 e_uint_t n=100;
40 T *p = allocator.allocate(n);
41 EXTL_ASSERT(p != NULL);
43 allocator.construct(p, 1987);
44 EXTL_ASSERT(*p == 1987);
46 T *pnew = allocator.reallocate(p, 1000);
47 EXTL_ASSERT(pnew != NULL);
48 EXTL_ASSERT(*pnew == 1987);
50 allocator.destroy(pnew);
52 EXTL_ASSERT((void_allocator == void_allocator));
53 EXTL_ASSERT(!(allocator != allocator));
55 allocator.deallocate(pnew);
57 #ifdef EXTL_MEMORY_ALLOCATOR_REBIND_SUPPORT
58 typedef typename_type_k A::template_qual_k rebind<e_char_t>::other_type CA;
59 CA char_allocator;
60 e_char_t *pc = char_allocator.allocate(n);
61 char_allocator.construct(pc, 'C');
62 EXTL_ASSERT(*pc == 'C');
63 char_allocator.deallocate(pc);
64 #endif
67 #if !defined(EXTL_COMPILER_IS_BORLAND) && !defined(EXTL_COMPILER_IS_DMC)
68 # ifdef EXTL_TEMPLATE_CLASS_DEFAULT_ARGUMENT_SUPPORT
69 virtual_allocator_test< e_uint_t > g_virtual_allocator_test;
70 # else
71 virtual_allocator_test< e_uint_t, virtual_allocator< e_uint_t > > g_virtual_allocator_test;
72 # endif
73 #endif
75 /* ///////////////////////////////////////////////////////////////////////
76 * ::unit_test namespace
78 EXTL_TEST_END_NAMESPACE
80 /* //////////////////////////////////////////////////////////////////// */
81 #endif /* EXTL_MEMORY_VIRTUAL_ALLOCATOR_TEST_H */
82 /* //////////////////////////////////////////////////////////////////// */