author | William Roberts <williamr@symbian.org> |
Thu, 22 Jul 2010 16:48:56 +0100 | |
branch | GCC_SURGE |
changeset 45 | 4b03adbd26ca |
parent 18 | 47c74d1534e1 |
parent 34 | 5fae379060a7 |
permissions | -rw-r--r-- |
31 | 1 |
#include <vector> |
2 |
#include <list> |
|
3 |
#if defined (STLPORT) && !defined (_STLP_NO_EXTENSIONS) |
|
4 |
# include <slist> |
|
5 |
#endif |
|
6 |
#include <deque> |
|
7 |
#include <set> |
|
8 |
#include <iterator> |
|
9 |
||
10 |
#include "cppunit/cppunit_proxy.h" |
|
11 |
||
12 |
#if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES) |
|
13 |
using namespace std; |
|
14 |
#endif |
|
15 |
||
16 |
// |
|
17 |
// TestCase class |
|
18 |
// |
|
19 |
class PtrSpecTest : public CPPUNIT_NS::TestCase |
|
20 |
{ |
|
21 |
CPPUNIT_TEST_SUITE(PtrSpecTest); |
|
22 |
#if (defined (__DMC__) && defined (_STLP_DEBUG)) |
|
23 |
CPPUNIT_IGNORE; |
|
24 |
#endif |
|
25 |
CPPUNIT_TEST(ptr_specialization_test); |
|
26 |
CPPUNIT_TEST_SUITE_END(); |
|
27 |
||
28 |
protected: |
|
34
5fae379060a7
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
31
diff
changeset
|
29 |
/// this seems to be compile only test but... |
31 | 30 |
void ptr_specialization_test(); |
31 |
||
32 |
template <class _Tp> |
|
33 |
struct unary_pred { |
|
34 |
bool operator () (_Tp *__ptr) const { |
|
35 |
return *__ptr == 0; |
|
36 |
} |
|
37 |
}; |
|
38 |
||
39 |
template <class _Tp> |
|
40 |
struct binary_pred { |
|
41 |
bool operator () (_Tp *__first, _Tp *__second) const { |
|
42 |
return *__first < *__second; |
|
43 |
} |
|
44 |
}; |
|
45 |
}; |
|
46 |
||
47 |
CPPUNIT_TEST_SUITE_REGISTRATION(PtrSpecTest); |
|
48 |
||
49 |
#define TEST_INSTANCIATE_CONTAINER(cont) \ |
|
50 |
template class cont<int*>; \ |
|
51 |
template class cont<int const*>; \ |
|
52 |
template class cont<int volatile*>; \ |
|
53 |
template class cont<int const volatile*> |
|
54 |
||
55 |
#if !defined(_MSC_VER) || (_MSC_VER > 1200) // excluding MSVC 6.0 |
|
56 |
TEST_INSTANCIATE_CONTAINER(vector); |
|
57 |
TEST_INSTANCIATE_CONTAINER(list); |
|
58 |
# if defined (STLPORT) && !defined (_STLP_NO_EXTENSIONS) |
|
59 |
TEST_INSTANCIATE_CONTAINER(slist); |
|
60 |
# endif |
|
61 |
TEST_INSTANCIATE_CONTAINER(deque); |
|
62 |
TEST_INSTANCIATE_CONTAINER(set); |
|
63 |
TEST_INSTANCIATE_CONTAINER(multiset); |
|
64 |
#endif |
|
65 |
||
66 |
//Function to test pointer to function support: |
|
67 |
void FTypeInstance() {} |
|
68 |
||
69 |
//Class to test pointer to member method support: |
|
70 |
class AClass { |
|
71 |
public: |
|
72 |
void func() {} |
|
73 |
}; |
|
74 |
||
75 |
// |
|
76 |
// tests implementation |
|
77 |
// |
|
78 |
void PtrSpecTest::ptr_specialization_test() |
|
79 |
{ |
|
80 |
# if !(defined (__DMC__) && defined (_STLP_DEBUG)) |
|
81 |
int *int_array[] = {0, 0, 0}; |
|
82 |
int const* cint_array[] = {0, 0, 0}; |
|
83 |
||
84 |
{ |
|
85 |
vector<void*> void_vect; |
|
86 |
deque<void*> void_deque; |
|
87 |
list<void*> void_list; |
|
88 |
#if defined (STLPORT) && !defined (_STLP_NO_EXTENSIONS) |
|
89 |
slist<void*> void_slist; |
|
90 |
#endif |
|
91 |
} |
|
92 |
||
93 |
{ |
|
94 |
typedef void (*FType)(); |
|
95 |
vector<FType> func_vector; |
|
96 |
func_vector.push_back(&FTypeInstance); |
|
97 |
} |
|
98 |
||
99 |
#if !defined(__GNUC__) || (__GNUC__ > 2) |
|
100 |
{ |
|
101 |
typedef void (AClass::*MFType)(); |
|
102 |
vector<MFType> mem_func_vector; |
|
103 |
mem_func_vector.push_back(&AClass::func); |
|
104 |
} |
|
105 |
#endif |
|
106 |
||
107 |
vector<int*> pint_vect; |
|
108 |
vector<int*> pint_vect2; |
|
109 |
vector<int const*> pcint_vect; |
|
110 |
list<int*> pint_list; |
|
111 |
list<int*> pint_list2; |
|
112 |
list<int const*> pcint_list; |
|
113 |
#if defined (STLPORT) && !defined (_STLP_NO_EXTENSIONS) |
|
114 |
slist<int*> pint_slist; |
|
115 |
slist<int*> pint_slist2; |
|
116 |
slist<int const*> pcint_slist; |
|
117 |
#endif |
|
118 |
deque<int*> pint_deque; |
|
119 |
deque<int*> pint_deque2; |
|
120 |
deque<int const*> pcint_deque; |
|
121 |
||
122 |
#ifdef _STLP_MEMBER_TEMPLATES |
|
123 |
vector<int*> pint_vect_from_list(pint_list.begin(), pint_list.end()); |
|
124 |
#endif |
|
125 |
pint_vect.insert(pint_vect.end(), pint_vect2.begin(), pint_vect2.end()); |
|
126 |
pint_vect.insert(pint_vect.end(), int_array, int_array + 3); |
|
127 |
pint_vect2.insert(pint_vect2.end(), int_array, int_array + 3); |
|
128 |
pcint_vect.insert(pcint_vect.end(), int_array, int_array + 3); |
|
129 |
pcint_vect.insert(pcint_vect.end(), cint_array, cint_array + 3); |
|
130 |
#if !defined(_STLP_DEBUG) || defined(_STLP_MEMBER_TEMPLATES) |
|
131 |
pcint_vect.insert(pcint_vect.end(), pint_vect2.begin(), pint_vect2.end()); |
|
132 |
#endif |
|
133 |
pcint_vect.insert(pcint_vect.end(), int_array, int_array + 3); |
|
134 |
#ifdef _STLP_MEMBER_TEMPLATES |
|
135 |
pint_vect.insert(pint_vect.end(), pint_list.begin(), pint_list.end()); |
|
136 |
pcint_vect.insert(pcint_vect.end(), pint_list.begin(), pint_list.end()); |
|
137 |
pcint_vect.insert(pcint_vect.end(), pcint_list.begin(), pcint_list.end()); |
|
138 |
pint_vect.assign(pint_list.begin(), pint_list.end()); |
|
139 |
pcint_vect.assign(pint_list.begin(), pint_list.end()); |
|
140 |
#endif |
|
141 |
pint_vect.assign(int_array, int_array + 3); |
|
142 |
pcint_vect.assign(int_array, int_array + 3); |
|
143 |
pcint_vect.assign(cint_array, cint_array + 3); |
|
144 |
copy(int_array, int_array + 3, back_inserter(pint_vect)); |
|
145 |
||
146 |
#ifdef _STLP_MEMBER_TEMPLATES |
|
147 |
pint_list.sort(binary_pred<int>()); |
|
148 |
pcint_list.sort(binary_pred<int const>()); |
|
149 |
pint_list.unique(binary_pred<int>()); |
|
150 |
pcint_list.unique(binary_pred<int const>()); |
|
151 |
pint_list.merge(pint_list, binary_pred<int>()); |
|
152 |
pcint_list.merge(pcint_list, binary_pred<int const>()); |
|
153 |
pint_list.remove_if(unary_pred<int>()); |
|
154 |
pcint_list.remove_if(unary_pred<int const>()); |
|
155 |
#endif |
|
156 |
||
157 |
copy(int_array, int_array + 3, back_inserter(pint_list)); |
|
158 |
copy(int_array, int_array + 3, back_inserter(pint_list2)); |
|
159 |
pint_list.insert(pint_list.end(), pint_list2.begin(), pint_list2.end()); |
|
160 |
#ifdef _STLP_MEMBER_TEMPLATES |
|
161 |
pcint_list.insert(pcint_list.end(), pint_list.begin(), pint_list.end()); |
|
162 |
#endif |
|
163 |
#if !defined(_STLP_DEBUG) || defined(_STLP_MEMBER_TEMPLATES) |
|
164 |
pint_list.insert(pint_list.end(), pint_vect.begin(), pint_vect.end()); |
|
165 |
pcint_list.insert(pcint_list.end(), pint_vect.begin(), pint_vect.end()); |
|
166 |
pcint_list.insert(pcint_list.end(), pcint_vect.begin(), pcint_vect.end()); |
|
167 |
list<int*> pint_list_from_vect(pint_vect.begin(), pint_vect.end()); |
|
168 |
pint_list.assign(pint_vect.begin(), pint_vect.end()); |
|
169 |
pcint_list.assign(pint_vect.begin(), pint_vect.end()); |
|
170 |
#endif |
|
171 |
pint_list.insert(pint_list.begin(), int_array, int_array + 3); |
|
172 |
pint_list.insert(pint_list.end(), int_array, int_array + 3); |
|
173 |
pcint_list.insert(pcint_list.end(), int_array, int_array + 3); |
|
174 |
pcint_list.insert(pcint_list.end(), cint_array, cint_array + 3); |
|
175 |
pint_list.assign(int_array, int_array + 3); |
|
176 |
pcint_list.assign(int_array, int_array + 3); |
|
177 |
pcint_list.assign(cint_array, cint_array + 3); |
|
178 |
//pint_list.assign(pcint_vect.begin(), pcint_vect.end()); |
|
179 |
||
180 |
#if defined (STLPORT) && !defined (_STLP_NO_EXTENSIONS) |
|
181 |
copy(int_array, int_array + 3, front_inserter(pint_slist)); |
|
182 |
copy(int_array, int_array + 3, front_inserter(pint_slist2)); |
|
183 |
pint_slist.insert(pint_slist.end(), pint_slist2.begin(), pint_slist2.end()); |
|
184 |
# if defined (_STLP_MEMBER_TEMPLATES) |
|
185 |
pcint_slist.insert(pcint_slist.end(), pint_slist.begin(), pint_slist.end()); |
|
186 |
# endif |
|
187 |
# if !defined (_STLP_DEBUG) || defined (_STLP_MEMBER_TEMPLATES) |
|
188 |
pint_slist.insert(pint_slist.end(), pint_vect.begin(), pint_vect.end()); |
|
189 |
pcint_slist.insert(pcint_slist.end(), pint_vect.begin(), pint_vect.end()); |
|
190 |
pcint_slist.insert(pcint_slist.end(), pcint_vect.begin(), pcint_vect.end()); |
|
191 |
slist<int*> pint_slist_from_vect(pint_vect.begin(), pint_vect.end()); |
|
192 |
pint_slist.assign(pint_vect.begin(), pint_vect.end()); |
|
193 |
pcint_slist.assign(pint_vect.begin(), pint_vect.end()); |
|
194 |
# endif |
|
195 |
pint_slist.insert(pint_slist.end(), int_array, int_array + 3); |
|
196 |
pcint_slist.insert(pcint_slist.end(), int_array, int_array + 3); |
|
197 |
pcint_slist.insert(pcint_slist.end(), cint_array, cint_array + 3); |
|
198 |
pint_slist.assign(int_array, int_array + 3); |
|
199 |
pcint_slist.assign(int_array, int_array + 3); |
|
200 |
pcint_slist.assign(cint_array, cint_array + 3); |
|
201 |
//pint_slist.assign(pcint_vect.begin(), pcint_vect.end()); |
|
202 |
#endif |
|
203 |
||
204 |
copy(int_array, int_array + 3, back_inserter(pint_deque)); |
|
205 |
copy(int_array, int_array + 3, back_inserter(pint_deque2)); |
|
206 |
pint_deque.insert(pint_deque.end(), pint_deque2.begin(), pint_deque2.end()); |
|
207 |
#ifdef _STLP_MEMBER_TEMPLATES |
|
208 |
pcint_deque.insert(pcint_deque.end(), pint_deque.begin(), pint_deque.end()); |
|
209 |
#endif |
|
210 |
#if !defined(_STLP_DEBUG) || defined(_STLP_MEMBER_TEMPLATES) |
|
211 |
pint_deque.insert(pint_deque.end(), pint_vect.begin(), pint_vect.end()); |
|
212 |
pcint_deque.insert(pcint_deque.end(), pint_vect.begin(), pint_vect.end()); |
|
213 |
pcint_deque.insert(pcint_deque.end(), pcint_vect.begin(), pcint_vect.end()); |
|
214 |
deque<int*> pint_deque_from_vect(pint_vect.begin(), pint_vect.end()); |
|
215 |
pint_deque.assign(pint_vect.begin(), pint_vect.end()); |
|
216 |
pcint_deque.assign(pint_vect.begin(), pint_vect.end()); |
|
217 |
#endif |
|
218 |
pint_deque.insert(pint_deque.end(), int_array, int_array + 3); |
|
219 |
pcint_deque.insert(pcint_deque.end(), int_array, int_array + 3); |
|
220 |
pcint_deque.insert(pcint_deque.end(), cint_array, cint_array + 3); |
|
221 |
pint_deque.assign(int_array, int_array + 3); |
|
222 |
pcint_deque.assign(int_array, int_array + 3); |
|
223 |
pcint_deque.assign(cint_array, cint_array + 3); |
|
224 |
# endif /* __DMC__ */ |
|
225 |
} |