1 //------------------------------------------------------------------------------
2 // FindInstatiationFuncTester.cpp
3 //
4 /**
5 Tests for find_instantiation_func(const char* name, const char* sig)
6 @note There are no tests for find_instantiation_func(const char*) as it
7 simply calls through to the version which takes an explicit sig,
8 setting that parameter to NULL.
9
10 Here's the use case matrix:
11
12 name sig
13 -------- --------
14 case 1 NULL NULL
15 case 2 bogus NULL
16 case 3 NULL bogus
17 case 4 bogus bogus
18 case 5 local NULL
19 case 6 remote NULL
20 case 7 local bogus
21 case 8 remote bogus
22 case 9 local good
23 case 10 remote good
24 */
25 //------------------------------------------------------------------------------
26
27 // Standard Includes -----------------------------------------------------------
28
29 // System Includes -------------------------------------------------------------
30
31 // Project Includes ------------------------------------------------------------
32
33 // Local Includes --------------------------------------------------------------
34 #include "FindInstantiationFuncTester.h"
35 #include "LocalTestObject.h"
36
37 // Local Defines ---------------------------------------------------------------
38
39 // Globals ---------------------------------------------------------------------
40
41 //------------------------------------------------------------------------------
42 /**
43 find_instantiation_func(const char* name, const char* sig)
44 @case Both parameters NULL
45 @param name NULL
46 @param sig NULL
47 @results Returns NULL
48 */
Case1()49 void TFindInstantiationFuncTester::Case1()
50 {
51 instantiation_func f = find_instantiation_func(NULL, NULL);
52 CPPUNIT_ASSERT(f == NULL);
53 }
54 //------------------------------------------------------------------------------
55 /**
56 find_instantiation_func(const char* name, const char* sig)
57 @case Bad name with NULL signature
58 @param name Invalid class name
59 @param sig NULL
60 @results Returns NULL
61 */
Case2()62 void TFindInstantiationFuncTester::Case2()
63 {
64 instantiation_func f = find_instantiation_func(gInvalidClassName, NULL);
65 CPPUNIT_ASSERT(f == NULL);
66 }
67 //------------------------------------------------------------------------------
68 /**
69 find_instantiation_func(const char* name, const char* sig)
70 @case NULL name with invalid signature
71 @param name NULL class name
72 @param sig Invalid signature
73 @results Returns NULL
74 */
Case3()75 void TFindInstantiationFuncTester::Case3()
76 {
77 instantiation_func f = find_instantiation_func(NULL, gInvalidSig);
78 CPPUNIT_ASSERT(f == NULL);
79 }
80 //------------------------------------------------------------------------------
81 /**
82 find_instantiation_func(const char* name, const char* sig)
83 @case Both params are invalid
84 @param name Invalid class name
85 @param sig Invalid signature
86 @results Returns NULL
87 */
Case4()88 void TFindInstantiationFuncTester::Case4()
89 {
90 instantiation_func f = find_instantiation_func(gInvalidClassName,
91 gInvalidSig);
92 CPPUNIT_ASSERT(f == NULL);
93 }
94 //------------------------------------------------------------------------------
95 /**
96 find_instantiation_func(const char* name, const char* sig)
97 @case Valid name of a locally implemented class with a
98 NULL signature
99 @param name Valid local class name
100 @param sig NULL signature
101 @results Returns valid function
102 */
Case5()103 void TFindInstantiationFuncTester::Case5()
104 {
105 instantiation_func f = find_instantiation_func(gLocalClassName, NULL);
106 CPPUNIT_ASSERT(f != NULL);
107
108 BMessage Archive;
109 Archive.AddString("class", gLocalClassName);
110 TIOTest* Test = dynamic_cast<TIOTest*>(f(&Archive));
111 CPPUNIT_ASSERT(Test != NULL);
112 }
113 //------------------------------------------------------------------------------
114 /**
115 find_instantiation_func(const char* name, const char* sig)
116 @case Valid name of a remotely implemented class with a
117 NULL signature
118 @param name Valid remote class name
119 @param sig NULL signature
120 @results Returns NULL
121 */
Case6()122 void TFindInstantiationFuncTester::Case6()
123 {
124 instantiation_func f = find_instantiation_func(gRemoteClassName, NULL);
125 CPPUNIT_ASSERT(f == NULL);
126 }
127 //------------------------------------------------------------------------------
128 /**
129 find_instantiation_func(const char* name, const char* sig)
130 @case Valid name of a locally implemented class with an
131 invalid signature
132 @param name Valid local class name
133 @param sig Invalid signature
134 @results Returns NULL
135 */
Case7()136 void TFindInstantiationFuncTester::Case7()
137 {
138 instantiation_func f = find_instantiation_func(gLocalClassName,
139 gInvalidSig);
140 CPPUNIT_ASSERT(f == NULL);
141 }
142 //------------------------------------------------------------------------------
143 /**
144 find_instantiation_func(const char* name, const char* sig)
145 @case Valid name of a remotely implemented class with an
146 invalid signature
147 @param name Valid remote class name
148 @param sig Invalid signature
149 @results Returns NULL
150 */
Case8()151 void TFindInstantiationFuncTester::Case8()
152 {
153 instantiation_func f = find_instantiation_func(gRemoteClassName,
154 gInvalidSig);
155 CPPUNIT_ASSERT(f == NULL);
156 }
157 //------------------------------------------------------------------------------
158 /**
159 find_instantiation_func(const char* name, const char* sig)
160 @case Valid name of a locally implemented class with a
161 valid signature
162 @param name Valid local class name
163 @param sig Valid signature
164 @results Returns valid function
165 @note This test is not currently used; can't obtain the local
166 signature without a BApplication object (gLocalSig is a
167 placeholder).
168 */
Case9()169 void TFindInstantiationFuncTester::Case9()
170 {
171 instantiation_func f = find_instantiation_func(gLocalClassName, gLocalSig);
172 CPPUNIT_ASSERT(f == NULL);
173 }
174 //------------------------------------------------------------------------------
175 /**
176 find_instantiation_func(const char* name, const char* sig)
177 @case Valid name of a remotely implemented class with a
178 valid signature
179 @param name Valid remote class name
180 @param sig Valid signature
181 @results Returns NULL
182 @note This case's results are because find_instantiation_func
183 doesn't actually load anything in order to do its work.
184 */
Case10()185 void TFindInstantiationFuncTester::Case10()
186 {
187 instantiation_func f = find_instantiation_func(gRemoteClassName,
188 gRemoteSig);
189 CPPUNIT_ASSERT(f == NULL);
190 }
191 //------------------------------------------------------------------------------
192 /**
193 find_instantiation_func(const char* name, const char* sig)
194 @case Archive is NULL
195 @param Archive NULL
196 */
Case1M()197 void TFindInstantiationFuncTester::Case1M()
198 {
199 instantiation_func f = find_instantiation_func((BMessage*)NULL);
200 CPPUNIT_ASSERT(f == NULL);
201 }
202 //------------------------------------------------------------------------------
203 /**
204 find_instantiation_func(const char* name, const char* sig)
205 @case Bad name with NULL signature
206 @param name Invalid class name
207 @param sig NULL
208 @results Returns NULL
209 */
Case2M()210 void TFindInstantiationFuncTester::Case2M()
211 {
212 BMessage Archive;
213 Archive.AddString("class", gInvalidClassName);
214 instantiation_func f = find_instantiation_func(&Archive);
215 CPPUNIT_ASSERT(f == NULL);
216 }
217 //------------------------------------------------------------------------------
218 /**
219 find_instantiation_func(const char* name, const char* sig)
220 @case NULL name with invalid signature
221 @param name NULL class name
222 @param sig Invalid signature
223 @results Returns NULL
224 */
Case3M()225 void TFindInstantiationFuncTester::Case3M()
226 {
227 BMessage Archive;
228 Archive.AddString("add_on", gInvalidSig);
229 instantiation_func f = find_instantiation_func(&Archive);
230 CPPUNIT_ASSERT(f == NULL);
231 }
232 //------------------------------------------------------------------------------
233 /**
234 find_instantiation_func(const char* name, const char* sig)
235 @case Both params are invalid
236 @param name Invalid class name
237 @param sig Invalid signature
238 @results Returns NULL
239 */
Case4M()240 void TFindInstantiationFuncTester::Case4M()
241 {
242 BMessage Archive;
243 Archive.AddString("class", gInvalidClassName);
244 Archive.AddString("add_on", gInvalidSig);
245 instantiation_func f = find_instantiation_func(&Archive);
246 CPPUNIT_ASSERT(f == NULL);
247 }
248 //------------------------------------------------------------------------------
249 /**
250 find_instantiation_func(const char* name, const char* sig)
251 @case Valid name of a locally implemented class with a
252 NULL signature
253 @param name Valid local class name
254 @param sig NULL signature
255 @results Returns valid function
256 */
Case5M()257 void TFindInstantiationFuncTester::Case5M()
258 {
259 BMessage Archive;
260 Archive.AddString("class", gLocalClassName);
261
262 instantiation_func f = find_instantiation_func(&Archive);
263 CPPUNIT_ASSERT(f != NULL);
264
265 TIOTest* Test = dynamic_cast<TIOTest*>(f(&Archive));
266 CPPUNIT_ASSERT(Test != NULL);
267 }
268 //------------------------------------------------------------------------------
269 /**
270 find_instantiation_func(const char* name, const char* sig)
271 @case Valid name of a remotely implemented class with a
272 NULL signature
273 @param name Valid remote class name
274 @param sig NULL signature
275 @results Returns NULL
276 */
Case6M()277 void TFindInstantiationFuncTester::Case6M()
278 {
279 BMessage Archive;
280 Archive.AddString("class", gRemoteClassName);
281 instantiation_func f = find_instantiation_func(&Archive);
282 CPPUNIT_ASSERT(f == NULL);
283 }
284 //------------------------------------------------------------------------------
285 /**
286 find_instantiation_func(const char* name, const char* sig)
287 @case Valid name of a locally implemented class with an
288 invalid signature
289 @param name Valid local class name
290 @param sig Invalid signature
291 @results Returns NULL
292 */
Case7M()293 void TFindInstantiationFuncTester::Case7M()
294 {
295 BMessage Archive;
296 Archive.AddString("class", gLocalClassName);
297 Archive.AddString("add_on", gInvalidSig);
298 instantiation_func f = find_instantiation_func(&Archive);
299 CPPUNIT_ASSERT(f == NULL);
300 }
301 //------------------------------------------------------------------------------
302 /**
303 find_instantiation_func(const char* name, const char* sig)
304 @case Valid name of a remotely implemented class with an
305 invalid signature
306 @param name Valid remote class name
307 @param sig Invalid signature
308 @results Returns NULL
309 */
Case8M()310 void TFindInstantiationFuncTester::Case8M()
311 {
312 BMessage Archive;
313 Archive.AddString("class", gRemoteClassName);
314 Archive.AddString("add_on", gInvalidSig);
315 instantiation_func f = find_instantiation_func(&Archive);
316 CPPUNIT_ASSERT(f == NULL);
317 }
318 //------------------------------------------------------------------------------
319 /**
320 find_instantiation_func(const char* name, const char* sig)
321 @case Valid name of a locally implemented class with a
322 valid signature
323 @param name Valid local class name
324 @param sig Valid signature
325 @results Returns valid function
326 @note This test is not currently used; can't obtain the local
327 signature without a BApplication object (gLocalSig is a
328 placeholder).
329 */
Case9M()330 void TFindInstantiationFuncTester::Case9M()
331 {
332 BMessage Archive;
333 Archive.AddString("class", gLocalClassName);
334 Archive.AddString("add_on", gLocalSig);
335 instantiation_func f = find_instantiation_func(&Archive);
336 CPPUNIT_ASSERT(f == NULL);
337 }
338 //------------------------------------------------------------------------------
339 /**
340 find_instantiation_func(const char* name, const char* sig)
341 @case Valid name of a remotely implemented class with a
342 valid signature
343 @param name Valid remote class name
344 @param sig Valid signature
345 @results Returns NULL
346 @note This case's results are because find_instantiation_func
347 doesn't actually load anything in order to do its work.
348 */
Case10M()349 void TFindInstantiationFuncTester::Case10M()
350 {
351 BMessage Archive;
352 Archive.AddString("class", gRemoteClassName);
353 Archive.AddString("add_on", gRemoteSig);
354 instantiation_func f = find_instantiation_func(&Archive);
355 CPPUNIT_ASSERT(f == NULL);
356 }
357 //------------------------------------------------------------------------------
Suite()358 CppUnit::Test* TFindInstantiationFuncTester::Suite()
359 {
360 CppUnit::TestSuite* SuiteOfTests = new CppUnit::TestSuite;
361
362 ADD_TEST(SuiteOfTests, TFindInstantiationFuncTester, Case1);
363 ADD_TEST(SuiteOfTests, TFindInstantiationFuncTester, Case2);
364 ADD_TEST(SuiteOfTests, TFindInstantiationFuncTester, Case3);
365 ADD_TEST(SuiteOfTests, TFindInstantiationFuncTester, Case4);
366 ADD_TEST(SuiteOfTests, TFindInstantiationFuncTester, Case5);
367 ADD_TEST(SuiteOfTests, TFindInstantiationFuncTester, Case6);
368 ADD_TEST(SuiteOfTests, TFindInstantiationFuncTester, Case7);
369 ADD_TEST(SuiteOfTests, TFindInstantiationFuncTester, Case8);
370 // ADD_TEST(SuiteOfTests, TFindInstantiationFuncTester, Case9);
371 ADD_TEST(SuiteOfTests, TFindInstantiationFuncTester, Case10);
372
373 // BMessage using versions
374 #if !defined(TEST_R5)
375 ADD_TEST(SuiteOfTests, TFindInstantiationFuncTester, Case1M);
376 #endif
377 ADD_TEST(SuiteOfTests, TFindInstantiationFuncTester, Case2M);
378 ADD_TEST(SuiteOfTests, TFindInstantiationFuncTester, Case3M);
379 ADD_TEST(SuiteOfTests, TFindInstantiationFuncTester, Case4M);
380 ADD_TEST(SuiteOfTests, TFindInstantiationFuncTester, Case5M);
381 ADD_TEST(SuiteOfTests, TFindInstantiationFuncTester, Case6M);
382 ADD_TEST(SuiteOfTests, TFindInstantiationFuncTester, Case7M);
383 ADD_TEST(SuiteOfTests, TFindInstantiationFuncTester, Case8M);
384 // ADD_TEST(SuiteOfTests, TFindInstantiationFuncTester, Case9M);
385 ADD_TEST(SuiteOfTests, TFindInstantiationFuncTester, Case10M);
386
387 return SuiteOfTests;
388 }
389 //------------------------------------------------------------------------------
390
391 /*
392 * $Log $
393 *
394 * $Id $
395 *
396 */
397
398
399
400