0
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include "ut_symbianunittest.h"
|
|
19 |
#include "symbianunittestresult.h"
|
|
20 |
#include <symbianunittestmacros.h>
|
|
21 |
|
|
22 |
// ---------------------------------------------------------------------------
|
|
23 |
//
|
|
24 |
// ---------------------------------------------------------------------------
|
|
25 |
//
|
|
26 |
UT_CSymbianUnitTest* UT_CSymbianUnitTest::NewL()
|
|
27 |
{
|
|
28 |
UT_CSymbianUnitTest* self = UT_CSymbianUnitTest::NewLC();
|
|
29 |
CleanupStack::Pop( self );
|
|
30 |
return self;
|
|
31 |
}
|
|
32 |
|
|
33 |
// ---------------------------------------------------------------------------
|
|
34 |
//
|
|
35 |
// ---------------------------------------------------------------------------
|
|
36 |
//
|
|
37 |
UT_CSymbianUnitTest* UT_CSymbianUnitTest::NewLC()
|
|
38 |
{
|
|
39 |
UT_CSymbianUnitTest* self = new( ELeave )UT_CSymbianUnitTest();
|
|
40 |
CleanupStack::PushL( self );
|
|
41 |
self->ConstructL();
|
|
42 |
return self;
|
|
43 |
}
|
|
44 |
|
|
45 |
// ---------------------------------------------------------------------------
|
|
46 |
//
|
|
47 |
// ---------------------------------------------------------------------------
|
|
48 |
//
|
|
49 |
UT_CSymbianUnitTest::UT_CSymbianUnitTest()
|
|
50 |
{
|
|
51 |
}
|
|
52 |
|
|
53 |
// ---------------------------------------------------------------------------
|
|
54 |
//
|
|
55 |
// ---------------------------------------------------------------------------
|
|
56 |
//
|
|
57 |
void UT_CSymbianUnitTest::ConstructL()
|
|
58 |
{
|
|
59 |
BASE_CONSTRUCT
|
|
60 |
ADD_SUT_WITH_SETUP_AND_TEARDOWN( SetupL, UT_NameL, Teardown )
|
|
61 |
ADD_SUT( UT_IsMemoryAllocationFailureSimulationUsedL )
|
|
62 |
ADD_SUT( UT_PanicInTestL )
|
|
63 |
ADD_SUT( UT_ErrorInSetupL )
|
|
64 |
ADD_SUT( UT_LeaveInTestL )
|
|
65 |
ADD_SUT( UT_MemoryLeakInTestL )
|
|
66 |
ADD_SUT( UT_FailingAssertsL )
|
|
67 |
ADD_SUT( UT_PassingAssertsL )
|
|
68 |
ADD_SUT( UT_TestCaseNamesL )
|
|
69 |
ADD_SUT( UT_TimeoutL )
|
|
70 |
}
|
|
71 |
|
|
72 |
// ---------------------------------------------------------------------------
|
|
73 |
//
|
|
74 |
// ---------------------------------------------------------------------------
|
|
75 |
//
|
|
76 |
UT_CSymbianUnitTest::~UT_CSymbianUnitTest()
|
|
77 |
{
|
|
78 |
}
|
|
79 |
|
|
80 |
// ---------------------------------------------------------------------------
|
|
81 |
// From MSymbianUnitTestObserver
|
|
82 |
// ---------------------------------------------------------------------------
|
|
83 |
//
|
|
84 |
void UT_CSymbianUnitTest::IncrementExecutedTestsCount()
|
|
85 |
{
|
|
86 |
iExecutedTestCount++;
|
|
87 |
}
|
|
88 |
|
|
89 |
// ---------------------------------------------------------------------------
|
|
90 |
//
|
|
91 |
// ---------------------------------------------------------------------------
|
|
92 |
//
|
|
93 |
void UT_CSymbianUnitTest::SetupL()
|
|
94 |
{
|
|
95 |
iTestResult = CSymbianUnitTestResult::NewL();
|
|
96 |
iUnitTest = UT_CSymbianUnitTest::NewL();
|
|
97 |
// Remove the test cases added in ConstructL.
|
|
98 |
// They will be replaced by the functions simulating failures.
|
|
99 |
iUnitTest->iTestCases.ResetAndDestroy();
|
|
100 |
iTestCaseNames = new (ELeave)CDesCArrayFlat(1);
|
|
101 |
}
|
|
102 |
|
|
103 |
// ---------------------------------------------------------------------------
|
|
104 |
//
|
|
105 |
// ---------------------------------------------------------------------------
|
|
106 |
//
|
|
107 |
void UT_CSymbianUnitTest::Teardown()
|
|
108 |
{
|
|
109 |
delete iUnitTest;
|
|
110 |
iUnitTest = NULL;
|
|
111 |
delete iTestResult;
|
|
112 |
iTestResult = NULL;
|
|
113 |
iExecutedTestCount = 0;
|
|
114 |
delete iTestCaseNames;
|
|
115 |
iTestCaseNames = 0;
|
|
116 |
}
|
|
117 |
|
|
118 |
// ---------------------------------------------------------------------------
|
|
119 |
//
|
|
120 |
// ---------------------------------------------------------------------------
|
|
121 |
//
|
|
122 |
void UT_CSymbianUnitTest::UT_NameL()
|
|
123 |
{
|
|
124 |
SUT_ASSERT_EQUALS( _L( "UT_CSymbianUnitTest" ), iUnitTest->Name() )
|
|
125 |
}
|
|
126 |
|
|
127 |
// ---------------------------------------------------------------------------
|
|
128 |
//
|
|
129 |
// ---------------------------------------------------------------------------
|
|
130 |
//
|
|
131 |
void UT_CSymbianUnitTest::UT_IsMemoryAllocationFailureSimulationUsedL()
|
|
132 |
{
|
|
133 |
SUT_ASSERT( !iUnitTest->IsMemoryAllocationFailureSimulationUsed() )
|
|
134 |
|
|
135 |
iUnitTest->iAllocFailureType = RHeap::EDeterministic;
|
|
136 |
SUT_ASSERT( iUnitTest->IsMemoryAllocationFailureSimulationUsed() )
|
|
137 |
}
|
|
138 |
|
|
139 |
// ---------------------------------------------------------------------------
|
|
140 |
//
|
|
141 |
// ---------------------------------------------------------------------------
|
|
142 |
//
|
|
143 |
void UT_CSymbianUnitTest::UT_PanicInTestL()
|
|
144 |
{
|
|
145 |
SUT_ASSERT_EQUALS( 0, iTestResult->Failures().Count() )
|
|
146 |
SUT_ASSERT_EQUALS( 0, iExecutedTestCount )
|
|
147 |
|
|
148 |
_LIT( KTestName, "PanicInTest" );
|
|
149 |
iUnitTest->AddTestCaseL(
|
|
150 |
KTestName,
|
|
151 |
CSymbianUnitTest::FunctionPtr( Dummy ),
|
|
152 |
CSymbianUnitTest::FunctionPtr( SimulatePanicL ),
|
|
153 |
CSymbianUnitTest::FunctionPtr( Dummy ) );
|
|
154 |
|
|
155 |
// Without memory allocation failure simulation
|
|
156 |
iUnitTest->ExecuteL( *this, *iTestResult, ENoFailureSimulation, *iTestCaseNames, 0 );
|
|
157 |
SUT_ASSERT_EQUALS( 1, iTestResult->Failures().Count() )
|
|
158 |
SUT_ASSERT_EQUALS( 1, iExecutedTestCount )
|
|
159 |
|
|
160 |
// With memory allocation failure simulation
|
|
161 |
iUnitTest->ExecuteL( *this, *iTestResult, EMemAllocFailureSimulation, *iTestCaseNames, 0 );
|
|
162 |
SUT_ASSERT_EQUALS( 2, iTestResult->Failures().Count() )
|
|
163 |
SUT_ASSERT_EQUALS( 2, iExecutedTestCount )
|
|
164 |
}
|
|
165 |
|
|
166 |
// ---------------------------------------------------------------------------
|
|
167 |
//
|
|
168 |
// ---------------------------------------------------------------------------
|
|
169 |
//
|
|
170 |
void UT_CSymbianUnitTest::UT_ErrorInSetupL()
|
|
171 |
{
|
|
172 |
SUT_ASSERT_EQUALS( 0, iTestResult->Failures().Count() )
|
|
173 |
SUT_ASSERT_EQUALS( 0, iExecutedTestCount )
|
|
174 |
|
|
175 |
_LIT( KTestName, "ErrorInSetup" );
|
|
176 |
iUnitTest->AddTestCaseL(
|
|
177 |
KTestName,
|
|
178 |
CSymbianUnitTest::FunctionPtr( SimulateLeaveL ),
|
|
179 |
CSymbianUnitTest::FunctionPtr( Dummy ),
|
|
180 |
CSymbianUnitTest::FunctionPtr( Dummy ) );
|
|
181 |
|
|
182 |
// Without memory allocation failure simulation
|
|
183 |
iUnitTest->ExecuteL( *this, *iTestResult, ENoFailureSimulation, *iTestCaseNames, 0 );
|
|
184 |
SUT_ASSERT_EQUALS( 1, iTestResult->Failures().Count() )
|
|
185 |
SUT_ASSERT_EQUALS( 1, iExecutedTestCount )
|
|
186 |
|
|
187 |
// With memory allocation failure simulation
|
|
188 |
iUnitTest->ExecuteL( *this, *iTestResult, EMemAllocFailureSimulation, *iTestCaseNames, 0 );
|
|
189 |
SUT_ASSERT_EQUALS( 2, iTestResult->Failures().Count() )
|
|
190 |
SUT_ASSERT_EQUALS( 2, iExecutedTestCount )
|
|
191 |
}
|
|
192 |
|
|
193 |
// ---------------------------------------------------------------------------
|
|
194 |
//
|
|
195 |
// ---------------------------------------------------------------------------
|
|
196 |
//
|
|
197 |
void UT_CSymbianUnitTest::UT_LeaveInTestL()
|
|
198 |
{
|
|
199 |
SUT_ASSERT_EQUALS( 0, iTestResult->Failures().Count() )
|
|
200 |
SUT_ASSERT_EQUALS( 0, iExecutedTestCount )
|
|
201 |
|
|
202 |
_LIT( KTestName, "LeaveInTest" );
|
|
203 |
iUnitTest->AddTestCaseL(
|
|
204 |
KTestName,
|
|
205 |
CSymbianUnitTest::FunctionPtr( Dummy ),
|
|
206 |
CSymbianUnitTest::FunctionPtr( SimulateLeaveL ),
|
|
207 |
CSymbianUnitTest::FunctionPtr( Dummy ) );
|
|
208 |
|
|
209 |
// Without memory allocation failure simulation
|
|
210 |
iUnitTest->ExecuteL( *this, *iTestResult, ENoFailureSimulation, *iTestCaseNames, 0);
|
|
211 |
SUT_ASSERT_EQUALS( 1, iTestResult->Failures().Count() )
|
|
212 |
SUT_ASSERT_EQUALS( 1, iExecutedTestCount )
|
|
213 |
|
|
214 |
// With memory allocation failure simulation
|
|
215 |
iUnitTest->ExecuteL( *this, *iTestResult, EMemAllocFailureSimulation, *iTestCaseNames, 0 );
|
|
216 |
SUT_ASSERT_EQUALS( 2, iTestResult->Failures().Count() )
|
|
217 |
SUT_ASSERT_EQUALS( 2, iExecutedTestCount )
|
|
218 |
}
|
|
219 |
|
|
220 |
// ---------------------------------------------------------------------------
|
|
221 |
//
|
|
222 |
// ---------------------------------------------------------------------------
|
|
223 |
//
|
|
224 |
void UT_CSymbianUnitTest::UT_MemoryLeakInTestL()
|
|
225 |
{
|
|
226 |
SUT_ASSERT_EQUALS( 0, iTestResult->Failures().Count() )
|
|
227 |
SUT_ASSERT_EQUALS( 0, iExecutedTestCount )
|
|
228 |
|
|
229 |
_LIT( KTestName, "MemoryLeakInTest" );
|
|
230 |
iUnitTest->AddTestCaseL(
|
|
231 |
KTestName,
|
|
232 |
CSymbianUnitTest::FunctionPtr( Dummy ),
|
|
233 |
CSymbianUnitTest::FunctionPtr( SimulateMemoryLeakL ),
|
|
234 |
CSymbianUnitTest::FunctionPtr( Dummy ) );
|
|
235 |
|
|
236 |
// Without memory allocation failure simulation
|
|
237 |
iUnitTest->ExecuteL( *this, *iTestResult, ENoFailureSimulation, *iTestCaseNames, 0 );
|
|
238 |
SUT_ASSERT_EQUALS( 1, iTestResult->Failures().Count() )
|
|
239 |
SUT_ASSERT_EQUALS( 1, iExecutedTestCount )
|
|
240 |
|
|
241 |
// With memory allocation failure simulation
|
|
242 |
iUnitTest->ExecuteL( *this, *iTestResult, EMemAllocFailureSimulation, *iTestCaseNames, 0 );
|
|
243 |
SUT_ASSERT_EQUALS( 2, iTestResult->Failures().Count() )
|
|
244 |
SUT_ASSERT_EQUALS( 2, iExecutedTestCount )
|
|
245 |
}
|
|
246 |
|
|
247 |
// ---------------------------------------------------------------------------
|
|
248 |
//
|
|
249 |
// ---------------------------------------------------------------------------
|
|
250 |
//
|
|
251 |
void UT_CSymbianUnitTest::UT_FailingAssertsL()
|
|
252 |
{
|
|
253 |
SUT_ASSERT_EQUALS( 0, iTestResult->Failures().Count() )
|
|
254 |
SUT_ASSERT_EQUALS( 0, iExecutedTestCount )
|
|
255 |
|
|
256 |
_LIT( KTestName, "TestAssertFailures" );
|
|
257 |
iUnitTest->AddTestCaseL(
|
|
258 |
KTestName,
|
|
259 |
CSymbianUnitTest::FunctionPtr( Dummy ),
|
|
260 |
CSymbianUnitTest::FunctionPtr( SimulateFailingAssertL ),
|
|
261 |
CSymbianUnitTest::FunctionPtr( Dummy ) );
|
|
262 |
iUnitTest->AddTestCaseL(
|
|
263 |
KTestName,
|
|
264 |
CSymbianUnitTest::FunctionPtr( Dummy ),
|
|
265 |
CSymbianUnitTest::FunctionPtr( SimulateFailingAssertWithIntsL ),
|
|
266 |
CSymbianUnitTest::FunctionPtr( Dummy ) );
|
|
267 |
iUnitTest->AddTestCaseL(
|
|
268 |
KTestName,
|
|
269 |
CSymbianUnitTest::FunctionPtr( Dummy ),
|
|
270 |
CSymbianUnitTest::FunctionPtr( SimulateFailingAssertWithDesC8sL ),
|
|
271 |
CSymbianUnitTest::FunctionPtr( Dummy ) );
|
|
272 |
iUnitTest->AddTestCaseL(
|
|
273 |
KTestName,
|
|
274 |
CSymbianUnitTest::FunctionPtr( Dummy ),
|
|
275 |
CSymbianUnitTest::FunctionPtr( SimulateFailingAssertWithDesC16sL ),
|
|
276 |
CSymbianUnitTest::FunctionPtr( Dummy ) );
|
|
277 |
iUnitTest->AddTestCaseL(
|
|
278 |
KTestName,
|
|
279 |
CSymbianUnitTest::FunctionPtr( Dummy ),
|
|
280 |
CSymbianUnitTest::FunctionPtr( SimulateFailingAssertLeaveL ),
|
|
281 |
CSymbianUnitTest::FunctionPtr( Dummy ) );
|
|
282 |
iUnitTest->AddTestCaseL(
|
|
283 |
KTestName,
|
|
284 |
CSymbianUnitTest::FunctionPtr( Dummy ),
|
|
285 |
CSymbianUnitTest::FunctionPtr( SimulateFailingAssertLeaveWithSpecificValueL ),
|
|
286 |
CSymbianUnitTest::FunctionPtr( Dummy ) );
|
|
287 |
|
|
288 |
// Without memory allocation failure simulation
|
|
289 |
iUnitTest->ExecuteL( *this, *iTestResult, ENoFailureSimulation, *iTestCaseNames, 0 );
|
|
290 |
SUT_ASSERT_EQUALS( 6, iTestResult->Failures().Count() )
|
|
291 |
SUT_ASSERT_EQUALS( 6, iExecutedTestCount )
|
|
292 |
|
|
293 |
// With memory allocation failure simulation
|
|
294 |
iUnitTest->ExecuteL( *this, *iTestResult, EMemAllocFailureSimulation, *iTestCaseNames, 0 );
|
|
295 |
SUT_ASSERT_EQUALS( 12, iTestResult->Failures().Count() )
|
|
296 |
SUT_ASSERT_EQUALS( 12, iExecutedTestCount )
|
|
297 |
}
|
|
298 |
|
|
299 |
// ---------------------------------------------------------------------------
|
|
300 |
//
|
|
301 |
// ---------------------------------------------------------------------------
|
|
302 |
//
|
|
303 |
void UT_CSymbianUnitTest::UT_PassingAssertsL()
|
|
304 |
{
|
|
305 |
SUT_ASSERT( ETrue )
|
|
306 |
SUT_ASSERT( ETrue == ETrue )
|
|
307 |
SUT_ASSERT( 1 == 1 )
|
|
308 |
HBufC* ptr( NULL );
|
|
309 |
SUT_ASSERT( !ptr )
|
|
310 |
ptr = KNullDesC().AllocLC();
|
|
311 |
SUT_ASSERT( ptr )
|
|
312 |
CleanupStack::PopAndDestroy( ptr );
|
|
313 |
|
|
314 |
SUT_ASSERT_EQUALS( 1, 1 )
|
|
315 |
SUT_ASSERT_EQUALS( KNullDesC8, KNullDesC8 )
|
|
316 |
SUT_ASSERT_EQUALS( KNullDesC, KNullDesC )
|
|
317 |
|
|
318 |
SUT_ASSERT_LEAVE( User::Leave( KErrNone ) )
|
|
319 |
SUT_ASSERT_LEAVE( User::Leave( KErrGeneral ) )
|
|
320 |
|
|
321 |
SUT_ASSERT_LEAVE_WITH( User::Leave( KErrGeneral ), KErrGeneral )
|
|
322 |
}
|
|
323 |
|
|
324 |
|
|
325 |
// ---------------------------------------------------------------------------
|
|
326 |
//
|
|
327 |
// ---------------------------------------------------------------------------
|
|
328 |
//
|
|
329 |
void UT_CSymbianUnitTest::UT_TestCaseNamesL()
|
|
330 |
{
|
|
331 |
SUT_ASSERT_EQUALS( 0, iTestResult->Failures().Count() )
|
|
332 |
SUT_ASSERT_EQUALS( 0, iExecutedTestCount )
|
|
333 |
|
|
334 |
_LIT( KTest1Name, "TestCase1" );
|
|
335 |
iUnitTest->AddTestCaseL(
|
|
336 |
KTest1Name,
|
|
337 |
CSymbianUnitTest::FunctionPtr( Dummy ),
|
|
338 |
CSymbianUnitTest::FunctionPtr( SimulateLeaveL ),
|
|
339 |
CSymbianUnitTest::FunctionPtr( Dummy ) );
|
|
340 |
|
|
341 |
_LIT( KTest2Name, "TestCase2" );
|
|
342 |
iUnitTest->AddTestCaseL(
|
|
343 |
KTest2Name,
|
|
344 |
CSymbianUnitTest::FunctionPtr( Dummy ),
|
|
345 |
CSymbianUnitTest::FunctionPtr( SimulateLeaveL ),
|
|
346 |
CSymbianUnitTest::FunctionPtr( Dummy ) );
|
|
347 |
|
|
348 |
_LIT( KTest3Name, "TestCase3" );
|
|
349 |
iUnitTest->AddTestCaseL(
|
|
350 |
KTest3Name,
|
|
351 |
CSymbianUnitTest::FunctionPtr( Dummy ),
|
|
352 |
CSymbianUnitTest::FunctionPtr( SimulateLeaveL ),
|
|
353 |
CSymbianUnitTest::FunctionPtr( Dummy ) );
|
|
354 |
|
|
355 |
_LIT( LTest1FullName, "UT_CSymbianUnitTest::TestCase1");
|
|
356 |
iTestCaseNames->AppendL(LTest1FullName);
|
|
357 |
|
|
358 |
// Without memory allocation failure simulation
|
|
359 |
iUnitTest->ExecuteL( *this, *iTestResult, ENoFailureSimulation, *iTestCaseNames, 0 );
|
|
360 |
SUT_ASSERT_EQUALS( 1, iTestResult->Failures().Count() )
|
|
361 |
SUT_ASSERT_EQUALS( 1, iExecutedTestCount )
|
|
362 |
}
|
|
363 |
|
|
364 |
// ---------------------------------------------------------------------------
|
|
365 |
//
|
|
366 |
// ---------------------------------------------------------------------------
|
|
367 |
//
|
|
368 |
void UT_CSymbianUnitTest::UT_TimeoutL()
|
|
369 |
{
|
|
370 |
_LIT( KTestName, "TimeoutTestCase" );
|
|
371 |
iUnitTest->AddTestCaseL(
|
|
372 |
KTestName,
|
|
373 |
CSymbianUnitTest::FunctionPtr( Dummy ),
|
|
374 |
CSymbianUnitTest::FunctionPtr( SimulateTimeoutL ),
|
|
375 |
CSymbianUnitTest::FunctionPtr( Dummy ) );
|
|
376 |
//run test case without timeout control
|
|
377 |
iUnitTest->ExecuteL( *this, *iTestResult, ENoFailureSimulation, *iTestCaseNames, 0 );
|
|
378 |
SUT_ASSERT_EQUALS( 0, iTestResult->Failures().Count() )
|
|
379 |
SUT_ASSERT_EQUALS( 1, iExecutedTestCount )
|
|
380 |
//run test case with 3 seconds time out
|
|
381 |
iUnitTest->ExecuteL( *this, *iTestResult, ENoFailureSimulation, *iTestCaseNames, 3 );
|
|
382 |
SUT_ASSERT_EQUALS( 1, iTestResult->Failures().Count() )
|
|
383 |
SUT_ASSERT_EQUALS( 2, iExecutedTestCount )
|
|
384 |
}
|
|
385 |
|
|
386 |
// ---------------------------------------------------------------------------
|
|
387 |
//
|
|
388 |
// ---------------------------------------------------------------------------
|
|
389 |
//
|
|
390 |
void UT_CSymbianUnitTest::SimulateTimeoutL()
|
|
391 |
{
|
|
392 |
User::After(5* 1000000);
|
|
393 |
}
|
|
394 |
|
|
395 |
|
|
396 |
// ---------------------------------------------------------------------------
|
|
397 |
//
|
|
398 |
// ---------------------------------------------------------------------------
|
|
399 |
//
|
|
400 |
void UT_CSymbianUnitTest::SimulatePanicL()
|
|
401 |
{
|
|
402 |
HBufC* tmp( NULL );
|
|
403 |
tmp->Length();
|
|
404 |
}
|
|
405 |
|
|
406 |
// ---------------------------------------------------------------------------
|
|
407 |
//
|
|
408 |
// ---------------------------------------------------------------------------
|
|
409 |
//
|
|
410 |
void UT_CSymbianUnitTest::SimulateLeaveL()
|
|
411 |
{
|
|
412 |
User::Leave( KErrGeneral );
|
|
413 |
}
|
|
414 |
|
|
415 |
// ---------------------------------------------------------------------------
|
|
416 |
//
|
|
417 |
// ---------------------------------------------------------------------------
|
|
418 |
//
|
|
419 |
void UT_CSymbianUnitTest::SimulateMemoryLeakL()
|
|
420 |
{
|
|
421 |
HBufC::NewL( 1 );
|
|
422 |
}
|
|
423 |
|
|
424 |
// ---------------------------------------------------------------------------
|
|
425 |
//
|
|
426 |
// ---------------------------------------------------------------------------
|
|
427 |
//
|
|
428 |
void UT_CSymbianUnitTest::SimulateFailingAssertL()
|
|
429 |
{
|
|
430 |
SUT_ASSERT( EFalse )
|
|
431 |
}
|
|
432 |
|
|
433 |
// ---------------------------------------------------------------------------
|
|
434 |
//
|
|
435 |
// ---------------------------------------------------------------------------
|
|
436 |
//
|
|
437 |
void UT_CSymbianUnitTest::SimulateFailingAssertWithIntsL()
|
|
438 |
{
|
|
439 |
const TInt KFirstValue( -1 );
|
|
440 |
const TInt KSecondValue( -2 );
|
|
441 |
SUT_ASSERT_EQUALS( KFirstValue, KSecondValue )
|
|
442 |
}
|
|
443 |
|
|
444 |
// ---------------------------------------------------------------------------
|
|
445 |
//
|
|
446 |
// ---------------------------------------------------------------------------
|
|
447 |
//
|
|
448 |
void UT_CSymbianUnitTest::SimulateFailingAssertWithDesC8sL()
|
|
449 |
{
|
|
450 |
_LIT8( KSomeText, "some text" );
|
|
451 |
SUT_ASSERT_EQUALS( KNullDesC8, KSomeText )
|
|
452 |
}
|
|
453 |
|
|
454 |
// ---------------------------------------------------------------------------
|
|
455 |
//
|
|
456 |
// ---------------------------------------------------------------------------
|
|
457 |
//
|
|
458 |
void UT_CSymbianUnitTest::SimulateFailingAssertWithDesC16sL()
|
|
459 |
{
|
|
460 |
_LIT( KSomeText, "some text" );
|
|
461 |
SUT_ASSERT_EQUALS( KNullDesC, KSomeText )
|
|
462 |
}
|
|
463 |
|
|
464 |
// ---------------------------------------------------------------------------
|
|
465 |
//
|
|
466 |
// ---------------------------------------------------------------------------
|
|
467 |
//
|
|
468 |
void UT_CSymbianUnitTest::SimulateFailingAssertLeaveL()
|
|
469 |
{
|
|
470 |
SUT_ASSERT_LEAVE( Dummy() )
|
|
471 |
}
|
|
472 |
|
|
473 |
// ---------------------------------------------------------------------------
|
|
474 |
//
|
|
475 |
// ---------------------------------------------------------------------------
|
|
476 |
//
|
|
477 |
void UT_CSymbianUnitTest::SimulateFailingAssertLeaveWithSpecificValueL()
|
|
478 |
{
|
|
479 |
SUT_ASSERT_LEAVE_WITH( User::Leave( KErrNotFound ), KErrGeneral )
|
|
480 |
}
|
|
481 |
|
|
482 |
// ---------------------------------------------------------------------------
|
|
483 |
//
|
|
484 |
// ---------------------------------------------------------------------------
|
|
485 |
//
|
|
486 |
void UT_CSymbianUnitTest::Dummy()
|
|
487 |
{
|
|
488 |
}
|