remove \r
[extl.git] / extl / smartptr / unit_test / shared_array_test.h
blobaed5d126aa5a22b2febff3b7457f0bde1778d576
1 /* ///////////////////////////////////////////////////////////////////////
2 * File: shared_array_test.h
4 * Created: 08.02.25
5 * Updated: 08.05.05
7 * Brief: Unit-testing
9 * [<Home>]
10 * Copyright (c) 2008-2020, Waruqi All rights reserved.
11 * //////////////////////////////////////////////////////////////////// */
12 #ifndef EXTL_SMART_PTR_SHARED_ARRAY_TEST_H
13 #define EXTL_SMART_PTR_SHARED_ARRAY_TEST_H
15 #ifndef EXTL_SMART_PTR_SHARED_ARRAY_H
16 # error This file must be included of shared_array.h
17 #endif
19 /* ///////////////////////////////////////////////////////////////////////
20 * ::unit_test namespace
22 EXTL_TEST_BEGIN_NAMESPACE
24 /* DMC Bug: The following code will be not compiled successfully if there is not the statement */
25 #ifdef EXTL_COMPILER_IS_DMC
26 shared_array<int> bug;
27 #endif
28 /* ///////////////////////////////////////////////////////////////////////
29 * Unit-testing
31 struct shared_array_test
33 struct int_array_deleter
35 void operator()(int *p)
37 /* EXTL_ASSERT(0); */
38 if(NULL != p) delete[] p;
42 #ifdef EXTL_TEMPLATE_CLASS_DEFAULT_ARGUMENT_SUPPORT
43 typedef shared_array<int> shared_int_array;
44 #else
45 typedef shared_array<int, new_allocator<int>::array_deleter_type > shared_int_array;
46 #endif
47 typedef shared_array<int, int_array_deleter> shared_array_array;
49 shared_array_test()
51 shared_int_array p1(new int[10]);
52 p1[0] = 10;
54 EXTL_ASSERT(p1.count() == 1);
57 shared_int_array p2(p1);
58 EXTL_ASSERT(p1.count() == 2);
59 EXTL_ASSERT(p2.count() == 2);
62 EXTL_ASSERT(p1.is_unique());
64 EXTL_ASSERT(p1[0] == 10);
65 EXTL_ASSERT(p1);
66 EXTL_ASSERT(p1 != NULL);
68 p4 = p1;
69 EXTL_ASSERT(p4.count() == 2);
70 EXTL_ASSERT(p1.count() == 2);
71 EXTL_ASSERT(p4[0] == 10);
73 p1 = p4;
74 EXTL_ASSERT(p4.count() == 2);
75 EXTL_ASSERT(p1.count() == 2);
77 EXTL_ASSERT(p1 == p4);
80 shared_int_array p4;
82 shared_array_test g_shared_array_test;
83 /* ///////////////////////////////////////////////////////////////////////
84 * ::unit_test namespace
86 EXTL_TEST_END_NAMESPACE
88 /* //////////////////////////////////////////////////////////////////// */
89 #endif /* EXTL_SMART_PTR_SHARED_ARRAY_TEST_H */
90 /* //////////////////////////////////////////////////////////////////// */