1 #include <cstdio> //size_t and STLport macros
3 #include "cppunit/cppunit_proxy.h"
8 class MoveConstructorTest
: public CPPUNIT_NS::TestCase
10 CPPUNIT_TEST_SUITE(MoveConstructorTest
);
11 CPPUNIT_TEST(move_construct_test
);
12 CPPUNIT_TEST(deque_test
);
13 CPPUNIT_TEST(vector_test
);
14 CPPUNIT_TEST(move_traits
);
15 #if !defined (STLPORT) || defined (_STLP_NO_MOVE_SEMANTIC) || \
16 defined (_STLP_DONT_SIMULATE_PARTIAL_SPEC_FOR_TYPE_TRAITS) || \
17 (defined (__BORLANDC__) && (__BORLANDC__ < 0x564))
20 CPPUNIT_TEST(movable_declaration
)
21 CPPUNIT_TEST(movable_declaration_assoc
)
22 CPPUNIT_TEST(movable_declaration_hash
)
23 #if defined (__BORLANDC__)
25 CPPUNIT_TEST(nb_destructor_calls
);
27 CPPUNIT_TEST_SUITE_END();
30 void move_construct_test();
34 void movable_declaration();
35 void movable_declaration_assoc();
36 void movable_declaration_hash();
37 void nb_destructor_calls();
40 template <class _Container>
41 void standard_test1(_Container const& ref_cont) {
42 vector<_Container> vec_cont(1, ref_cont);
43 typedef typename _Container::value_type value_type;
44 value_type *pvalue = &(*vec_cont.front().begin());
45 size_t cur_capacity= vec_cont.capacity();
47 while (cur_capacity == vec_cont.capacity()) {
48 vec_cont.push_back(ref_cont);
50 bool b=( (pvalue==(&(*vec_cont.front().begin()))) );
56 void move_traits_vec();
57 void move_traits_vec_complete();
58 void move_traits_deq();
59 void move_traits_deq_complete();
62 struct MovableStruct
{
63 MovableStruct() { ++nb_dft_construct_call
; }
64 MovableStruct(MovableStruct
const&) { ++nb_cpy_construct_call
; }
65 #if defined (STLPORT) && !defined (_STLP_NO_MOVE_SEMANTIC)
66 # if defined (_STLP_USE_NAMESPACES)
67 MovableStruct(std::__move_source
<MovableStruct
>)
69 MovableStruct(__move_source
<MovableStruct
>)
71 { ++nb_mv_construct_call
; }
73 ~MovableStruct() { ++nb_destruct_call
; }
75 MovableStruct
& operator = (const MovableStruct
&) {
81 nb_dft_construct_call
= nb_cpy_construct_call
= nb_mv_construct_call
= 0;
82 nb_assignment_call
= 0;
86 static size_t nb_dft_construct_call
;
87 static size_t nb_cpy_construct_call
;
88 static size_t nb_mv_construct_call
;
89 static size_t nb_assignment_call
;
90 static size_t nb_destruct_call
;
92 //Dummy data just to control struct sizeof
93 //As node allocator implementation align memory blocks on 2 * sizeof(void*)
94 //we give MovableStruct the same size in order to have expected allocation