1 /* ///////////////////////////////////////////////////////////////////////
2 * File: shared_array_test.h
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
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
;
28 /* ///////////////////////////////////////////////////////////////////////
31 struct shared_array_test
33 struct int_array_deleter
35 void operator()(int *p
)
38 if(NULL
!= p
) delete[] p
;
42 #ifdef EXTL_TEMPLATE_CLASS_DEFAULT_ARGUMENT_SUPPORT
43 typedef shared_array
<int> shared_int_array
;
45 typedef shared_array
<int, new_allocator
<int>::array_deleter_type
> shared_int_array
;
47 typedef shared_array
<int, int_array_deleter
> shared_array_array
;
51 shared_int_array
p1(new int[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);
66 EXTL_ASSERT(p1
!= NULL
);
69 EXTL_ASSERT(p4
.count() == 2);
70 EXTL_ASSERT(p1
.count() == 2);
71 EXTL_ASSERT(p4
[0] == 10);
74 EXTL_ASSERT(p4
.count() == 2);
75 EXTL_ASSERT(p1
.count() == 2);
77 EXTL_ASSERT(p1
== 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 /* //////////////////////////////////////////////////////////////////// */