testexecfw/symbianunittestfw/sutfw/sutfwcore/sutfwframework/tsrc/src/ut_symbianunittest.cpp
changeset 1 bbd31066657e
parent 0 3e07fef1e154
equal deleted inserted replaced
0:3e07fef1e154 1:bbd31066657e
    13 *
    13 *
    14 * Description:  
    14 * Description:  
    15 *
    15 *
    16 */
    16 */
    17 
    17 
       
    18 #include "sutlogger.h"
    18 #include "ut_symbianunittest.h"
    19 #include "ut_symbianunittest.h"
    19 #include "symbianunittestresult.h"
    20 #include "symbianunittestresult.h"
    20 #include <symbianunittestmacros.h>
    21 #include <symbianunittestmacros.h>
    21 
    22 
    22 // ---------------------------------------------------------------------------
    23 // ---------------------------------------------------------------------------
    46 //
    47 //
    47 // ---------------------------------------------------------------------------
    48 // ---------------------------------------------------------------------------
    48 //
    49 //
    49 UT_CSymbianUnitTest::UT_CSymbianUnitTest()
    50 UT_CSymbianUnitTest::UT_CSymbianUnitTest()
    50     {
    51     {
       
    52     SUT_LOG_DEBUG( "Entering UT_CSymbianUnitTest::UT_CSymbianUnitTest()" )
       
    53     SUT_LOG_DEBUG( "Exiting UT_CSymbianUnitTest::UT_CSymbianUnitTest()" )
    51     }
    54     }
    52 
    55 
    53 // ---------------------------------------------------------------------------
    56 // ---------------------------------------------------------------------------
    54 //
    57 //
    55 // ---------------------------------------------------------------------------
    58 // ---------------------------------------------------------------------------
    56 //
    59 //
    57 void UT_CSymbianUnitTest::ConstructL()
    60 void UT_CSymbianUnitTest::ConstructL()
    58     {
    61     {
    59     BASE_CONSTRUCT
    62     BASE_CONSTRUCT
       
    63     
       
    64     DEFINE_TEST_CLASS( UT_CSymbianUnitTest )
       
    65     
    60     ADD_SUT_WITH_SETUP_AND_TEARDOWN( SetupL, UT_NameL, Teardown )
    66     ADD_SUT_WITH_SETUP_AND_TEARDOWN( SetupL, UT_NameL, Teardown )
    61     ADD_SUT( UT_IsMemoryAllocationFailureSimulationUsedL )
    67     ADD_SUT( UT_IsMemoryAllocationFailureSimulationUsedL )
    62     ADD_SUT( UT_PanicInTestL )
    68     ADD_SUT( UT_PanicInTestL )
    63     ADD_SUT( UT_ErrorInSetupL )
    69     ADD_SUT( UT_ErrorInSetupL )
    64     ADD_SUT( UT_LeaveInTestL )
    70     ADD_SUT( UT_LeaveInTestL )
    65     ADD_SUT( UT_MemoryLeakInTestL )
    71     ADD_SUT( UT_MemoryLeakInTestL ) 
       
    72     ADD_SUT( UT_EqualsAssertsL )
    66     ADD_SUT( UT_FailingAssertsL )
    73     ADD_SUT( UT_FailingAssertsL )
    67     ADD_SUT( UT_PassingAssertsL )
    74     ADD_SUT( UT_PassingAssertsL )
    68     ADD_SUT( UT_TestCaseNamesL )
    75     ADD_SUT( UT_TestCaseNamesL )
    69     ADD_SUT( UT_TimeoutL )
    76     ADD_SUT( UT_TimeoutL )
    70     }
    77     }
   146     SUT_ASSERT_EQUALS( 0, iExecutedTestCount )
   153     SUT_ASSERT_EQUALS( 0, iExecutedTestCount )
   147  
   154  
   148     _LIT( KTestName, "PanicInTest" );
   155     _LIT( KTestName, "PanicInTest" );
   149     iUnitTest->AddTestCaseL( 
   156     iUnitTest->AddTestCaseL( 
   150         KTestName, 
   157         KTestName, 
   151         CSymbianUnitTest::FunctionPtr( Dummy ), 
   158         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ), 
   152         CSymbianUnitTest::FunctionPtr( SimulatePanicL ), 
   159         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::SimulatePanicL ), 
   153         CSymbianUnitTest::FunctionPtr( Dummy ) );
   160         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ) );
   154     
   161     
   155     // Without memory allocation failure simulation
   162     // Without memory allocation failure simulation
   156     iUnitTest->ExecuteL( *this, *iTestResult, ENoFailureSimulation, *iTestCaseNames, 0 );
   163     iUnitTest->ExecuteL( *this, *iTestResult, ENoFailureSimulation, *iTestCaseNames, 0 );
   157     SUT_ASSERT_EQUALS( 1, iTestResult->Failures().Count() )
   164     SUT_ASSERT_EQUALS( 1, iTestResult->Failures().Count() )
   158     SUT_ASSERT_EQUALS( 1, iExecutedTestCount )
   165     SUT_ASSERT_EQUALS( 1, iExecutedTestCount )
   173     SUT_ASSERT_EQUALS( 0, iExecutedTestCount )
   180     SUT_ASSERT_EQUALS( 0, iExecutedTestCount )
   174  
   181  
   175     _LIT( KTestName, "ErrorInSetup" );
   182     _LIT( KTestName, "ErrorInSetup" );
   176     iUnitTest->AddTestCaseL( 
   183     iUnitTest->AddTestCaseL( 
   177         KTestName, 
   184         KTestName, 
   178         CSymbianUnitTest::FunctionPtr( SimulateLeaveL ), 
   185         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::SimulateLeaveL ), 
   179         CSymbianUnitTest::FunctionPtr( Dummy ), 
   186         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ), 
   180         CSymbianUnitTest::FunctionPtr( Dummy ) );
   187         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ) );
   181     
   188     
   182     // Without memory allocation failure simulation
   189     // Without memory allocation failure simulation
   183     iUnitTest->ExecuteL( *this, *iTestResult, ENoFailureSimulation, *iTestCaseNames, 0 );
   190     iUnitTest->ExecuteL( *this, *iTestResult, ENoFailureSimulation, *iTestCaseNames, 0 );
   184     SUT_ASSERT_EQUALS( 1, iTestResult->Failures().Count() )
   191     SUT_ASSERT_EQUALS( 1, iTestResult->Failures().Count() )
   185     SUT_ASSERT_EQUALS( 1, iExecutedTestCount )
   192     SUT_ASSERT_EQUALS( 1, iExecutedTestCount )
   200     SUT_ASSERT_EQUALS( 0, iExecutedTestCount )
   207     SUT_ASSERT_EQUALS( 0, iExecutedTestCount )
   201  
   208  
   202     _LIT( KTestName, "LeaveInTest" );
   209     _LIT( KTestName, "LeaveInTest" );
   203     iUnitTest->AddTestCaseL( 
   210     iUnitTest->AddTestCaseL( 
   204         KTestName, 
   211         KTestName, 
   205         CSymbianUnitTest::FunctionPtr( Dummy ), 
   212         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ), 
   206         CSymbianUnitTest::FunctionPtr( SimulateLeaveL ), 
   213         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::SimulateLeaveL ), 
   207         CSymbianUnitTest::FunctionPtr( Dummy ) );
   214         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ) );
   208     
   215     
   209     // Without memory allocation failure simulation
   216     // Without memory allocation failure simulation
   210     iUnitTest->ExecuteL( *this, *iTestResult, ENoFailureSimulation, *iTestCaseNames, 0);
   217     iUnitTest->ExecuteL( *this, *iTestResult, ENoFailureSimulation, *iTestCaseNames, 0);
   211     SUT_ASSERT_EQUALS( 1, iTestResult->Failures().Count() )
   218     SUT_ASSERT_EQUALS( 1, iTestResult->Failures().Count() )
   212     SUT_ASSERT_EQUALS( 1, iExecutedTestCount )
   219     SUT_ASSERT_EQUALS( 1, iExecutedTestCount )
   227     SUT_ASSERT_EQUALS( 0, iExecutedTestCount )
   234     SUT_ASSERT_EQUALS( 0, iExecutedTestCount )
   228     
   235     
   229     _LIT( KTestName, "MemoryLeakInTest" );
   236     _LIT( KTestName, "MemoryLeakInTest" );
   230     iUnitTest->AddTestCaseL( 
   237     iUnitTest->AddTestCaseL( 
   231         KTestName, 
   238         KTestName, 
   232         CSymbianUnitTest::FunctionPtr( Dummy ), 
   239         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ), 
   233         CSymbianUnitTest::FunctionPtr( SimulateMemoryLeakL ), 
   240         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::SimulateMemoryLeakL ), 
   234         CSymbianUnitTest::FunctionPtr( Dummy ) );
   241         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ) );
   235     
   242     
   236     // Without memory allocation failure simulation
   243     // Without memory allocation failure simulation
   237     iUnitTest->ExecuteL( *this, *iTestResult, ENoFailureSimulation, *iTestCaseNames, 0 );
   244     iUnitTest->ExecuteL( *this, *iTestResult, ENoFailureSimulation, *iTestCaseNames, 0 );
   238     SUT_ASSERT_EQUALS( 1, iTestResult->Failures().Count() )
   245     SUT_ASSERT_EQUALS( 1, iTestResult->Failures().Count() )
   239     SUT_ASSERT_EQUALS( 1, iExecutedTestCount )
   246     SUT_ASSERT_EQUALS( 1, iExecutedTestCount )
   246 
   253 
   247 // ---------------------------------------------------------------------------
   254 // ---------------------------------------------------------------------------
   248 //
   255 //
   249 // ---------------------------------------------------------------------------
   256 // ---------------------------------------------------------------------------
   250 //
   257 //
       
   258 void UT_CSymbianUnitTest::UT_EqualsAssertsL()
       
   259 	{
       
   260 	SUT_ASSERT_EQUALS( 0, iTestResult->Failures().Count() )
       
   261     SUT_ASSERT_EQUALS( 0, iExecutedTestCount )
       
   262     
       
   263     _LIT( KTestName, "TestAssertEquals" );
       
   264     
       
   265     iUnitTest->AddTestCaseL( 
       
   266         KTestName, 
       
   267         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ), 
       
   268         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::SimulateEqualsAssertWithStringL ),
       
   269         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ) );
       
   270         
       
   271 
       
   272     iUnitTest->AddTestCaseL( 
       
   273         KTestName, 
       
   274         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ), 
       
   275         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::SimulateEqualsAssertWithStringFailL ),
       
   276         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ) );
       
   277         
       
   278         
       
   279     iUnitTest->AddTestCaseL( 
       
   280         KTestName, 
       
   281         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ), 
       
   282         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::SimulateEqualsAssertWithString8L ),
       
   283         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ) );
       
   284         
       
   285     iUnitTest->AddTestCaseL( 
       
   286         KTestName, 
       
   287         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ), 
       
   288         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::SimulateEqualsAssertWithString8FailL ),
       
   289         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ) );
       
   290 
       
   291     iUnitTest->AddTestCaseL( 
       
   292         KTestName, 
       
   293         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ), 
       
   294         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::SimulateEqualsAssertWithIntL ),
       
   295         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ) );
       
   296         
       
   297     iUnitTest->AddTestCaseL( 
       
   298         KTestName, 
       
   299         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ), 
       
   300         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::SimulateEqualsAssertWithIntFailL ),
       
   301         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ) );
       
   302 
       
   303     // Without memory allocation failure simulation
       
   304     iUnitTest->ExecuteL( *this, *iTestResult, ENoFailureSimulation, *iTestCaseNames, 0 );
       
   305     SUT_ASSERT_EQUALS( 3, iTestResult->Failures().Count() )
       
   306     SUT_ASSERT_EQUALS( 6, iExecutedTestCount )
       
   307     
       
   308     // With memory allocation failure simulation
       
   309     iUnitTest->ExecuteL( *this, *iTestResult, EMemAllocFailureSimulation, *iTestCaseNames, 0 );
       
   310     SUT_ASSERT_EQUALS( 6, iTestResult->Failures().Count() )
       
   311     SUT_ASSERT_EQUALS( 12, iExecutedTestCount )
       
   312 	}
       
   313 
       
   314 // ---------------------------------------------------------------------------
       
   315 //
       
   316 // ---------------------------------------------------------------------------
       
   317 //
   251 void UT_CSymbianUnitTest::UT_FailingAssertsL()
   318 void UT_CSymbianUnitTest::UT_FailingAssertsL()
   252     {
   319     {
   253     SUT_ASSERT_EQUALS( 0, iTestResult->Failures().Count() )
   320     SUT_ASSERT_EQUALS( 0, iTestResult->Failures().Count() )
   254     SUT_ASSERT_EQUALS( 0, iExecutedTestCount )
   321     SUT_ASSERT_EQUALS( 0, iExecutedTestCount )
   255     
   322     
   256     _LIT( KTestName, "TestAssertFailures" );
   323     _LIT( KTestName, "TestAssertFailures" );
   257     iUnitTest->AddTestCaseL( 
   324     iUnitTest->AddTestCaseL( 
   258         KTestName, 
   325         KTestName, 
   259         CSymbianUnitTest::FunctionPtr( Dummy ), 
   326         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ), 
   260         CSymbianUnitTest::FunctionPtr( SimulateFailingAssertL ),
   327         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::SimulateFailingAssertL ),
   261         CSymbianUnitTest::FunctionPtr( Dummy ) );
   328         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ) );
   262     iUnitTest->AddTestCaseL( 
   329     iUnitTest->AddTestCaseL( 
   263         KTestName, 
   330         KTestName, 
   264         CSymbianUnitTest::FunctionPtr( Dummy ), 
   331         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ), 
   265         CSymbianUnitTest::FunctionPtr( SimulateFailingAssertWithIntsL ),
   332         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::SimulateFailingAssertWithIntsL ),
   266         CSymbianUnitTest::FunctionPtr( Dummy ) );   
   333         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ) );   
   267     iUnitTest->AddTestCaseL( 
   334     iUnitTest->AddTestCaseL( 
   268         KTestName, 
   335         KTestName, 
   269         CSymbianUnitTest::FunctionPtr( Dummy ), 
   336         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ), 
   270         CSymbianUnitTest::FunctionPtr( SimulateFailingAssertWithDesC8sL ),
   337         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::SimulateFailingAssertWithDesC8sL ),
   271         CSymbianUnitTest::FunctionPtr( Dummy ) );    
   338         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ) );    
   272     iUnitTest->AddTestCaseL( 
   339     iUnitTest->AddTestCaseL( 
   273         KTestName, 
   340         KTestName, 
   274         CSymbianUnitTest::FunctionPtr( Dummy ), 
   341         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ), 
   275         CSymbianUnitTest::FunctionPtr( SimulateFailingAssertWithDesC16sL ),
   342         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::SimulateFailingAssertWithDesC16sL ),
   276         CSymbianUnitTest::FunctionPtr( Dummy ) ); 
   343         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ) ); 
   277     iUnitTest->AddTestCaseL( 
   344     iUnitTest->AddTestCaseL( 
   278         KTestName, 
   345         KTestName, 
   279         CSymbianUnitTest::FunctionPtr( Dummy ), 
   346         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ), 
   280         CSymbianUnitTest::FunctionPtr( SimulateFailingAssertLeaveL ),
   347         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::SimulateFailingAssertLeaveL ),
   281         CSymbianUnitTest::FunctionPtr( Dummy ) );
   348         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ) );
   282     iUnitTest->AddTestCaseL( 
   349     iUnitTest->AddTestCaseL( 
   283         KTestName, 
   350         KTestName, 
   284         CSymbianUnitTest::FunctionPtr( Dummy ), 
   351         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ), 
   285         CSymbianUnitTest::FunctionPtr( SimulateFailingAssertLeaveWithSpecificValueL ),
   352         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::SimulateFailingAssertLeaveWithSpecificValueL ),
   286         CSymbianUnitTest::FunctionPtr( Dummy ) );
   353         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ) );
   287     
   354     
   288     // Without memory allocation failure simulation
   355     // Without memory allocation failure simulation
   289     iUnitTest->ExecuteL( *this, *iTestResult, ENoFailureSimulation, *iTestCaseNames, 0 );
   356     iUnitTest->ExecuteL( *this, *iTestResult, ENoFailureSimulation, *iTestCaseNames, 0 );
   290     SUT_ASSERT_EQUALS( 6, iTestResult->Failures().Count() )
   357     SUT_ASSERT_EQUALS( 6, iTestResult->Failures().Count() )
   291     SUT_ASSERT_EQUALS( 6, iExecutedTestCount )
   358     SUT_ASSERT_EQUALS( 6, iExecutedTestCount )
   301 // ---------------------------------------------------------------------------
   368 // ---------------------------------------------------------------------------
   302 //
   369 //
   303 void UT_CSymbianUnitTest::UT_PassingAssertsL()
   370 void UT_CSymbianUnitTest::UT_PassingAssertsL()
   304     {
   371     {
   305     SUT_ASSERT( ETrue )
   372     SUT_ASSERT( ETrue )
       
   373     SUT_ASSERT_DESC( ETrue, "test assert with desc")
   306     SUT_ASSERT( ETrue == ETrue )
   374     SUT_ASSERT( ETrue == ETrue )
   307     SUT_ASSERT( 1 == 1 )
   375     SUT_ASSERT( 1 == 1 )
   308     HBufC* ptr( NULL );
   376     HBufC* ptr( NULL );
   309     SUT_ASSERT( !ptr )
   377     SUT_ASSERT( !ptr )
   310     ptr = KNullDesC().AllocLC();
   378     ptr = KNullDesC().AllocLC();
   311     SUT_ASSERT( ptr )
   379     SUT_ASSERT( ptr )
   312     CleanupStack::PopAndDestroy( ptr );
   380     CleanupStack::PopAndDestroy( ptr );
   313     
   381     
   314     SUT_ASSERT_EQUALS( 1, 1 )
   382     SUT_ASSERT_EQUALS( 1, 1 )
       
   383     SUT_ASSERT_EQUALS_DESC( 1, 1, "test assert equals with desc" )
   315     SUT_ASSERT_EQUALS( KNullDesC8, KNullDesC8 )
   384     SUT_ASSERT_EQUALS( KNullDesC8, KNullDesC8 )
   316     SUT_ASSERT_EQUALS( KNullDesC, KNullDesC )
   385     SUT_ASSERT_EQUALS( KNullDesC, KNullDesC )
   317     
   386     
   318     SUT_ASSERT_LEAVE( User::Leave( KErrNone ) )
       
   319     SUT_ASSERT_LEAVE( User::Leave( KErrGeneral ) )
   387     SUT_ASSERT_LEAVE( User::Leave( KErrGeneral ) )
   320     
   388     
   321     SUT_ASSERT_LEAVE_WITH( User::Leave( KErrGeneral ), KErrGeneral )
   389     SUT_ASSERT_LEAVE_WITH( User::Leave( KErrGeneral ), KErrGeneral )
   322     }
   390     }
   323 
   391 
   332     SUT_ASSERT_EQUALS( 0, iExecutedTestCount )
   400     SUT_ASSERT_EQUALS( 0, iExecutedTestCount )
   333  
   401  
   334     _LIT( KTest1Name, "TestCase1" );
   402     _LIT( KTest1Name, "TestCase1" );
   335     iUnitTest->AddTestCaseL( 
   403     iUnitTest->AddTestCaseL( 
   336         KTest1Name, 
   404         KTest1Name, 
   337         CSymbianUnitTest::FunctionPtr( Dummy ), 
   405         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ), 
   338         CSymbianUnitTest::FunctionPtr( SimulateLeaveL ), 
   406         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::SimulateLeaveL ), 
   339         CSymbianUnitTest::FunctionPtr( Dummy ) );
   407         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ) );
   340 
   408 
   341     _LIT( KTest2Name, "TestCase2" );
   409     _LIT( KTest2Name, "TestCase2" );
   342     iUnitTest->AddTestCaseL( 
   410     iUnitTest->AddTestCaseL( 
   343         KTest2Name, 
   411         KTest2Name, 
   344         CSymbianUnitTest::FunctionPtr( Dummy ), 
   412         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ), 
   345         CSymbianUnitTest::FunctionPtr( SimulateLeaveL ), 
   413         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::SimulateLeaveL ), 
   346         CSymbianUnitTest::FunctionPtr( Dummy ) );
   414         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ) );
   347 
   415 
   348     _LIT( KTest3Name, "TestCase3" );
   416     _LIT( KTest3Name, "TestCase3" );
   349     iUnitTest->AddTestCaseL( 
   417     iUnitTest->AddTestCaseL( 
   350         KTest3Name, 
   418         KTest3Name, 
   351         CSymbianUnitTest::FunctionPtr( Dummy ), 
   419         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ), 
   352         CSymbianUnitTest::FunctionPtr( SimulateLeaveL ), 
   420         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::SimulateLeaveL ), 
   353         CSymbianUnitTest::FunctionPtr( Dummy ) );
   421         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ) );
   354 
   422 
   355     _LIT( LTest1FullName, "UT_CSymbianUnitTest::TestCase1");
   423     _LIT( LTest1FullName, "UT_CSymbianUnitTest::TestCase1");
   356     iTestCaseNames->AppendL(LTest1FullName);
   424     iTestCaseNames->AppendL(LTest1FullName);
   357     
   425     
   358     // Without memory allocation failure simulation
   426     // Without memory allocation failure simulation
   368 void UT_CSymbianUnitTest::UT_TimeoutL()
   436 void UT_CSymbianUnitTest::UT_TimeoutL()
   369     {
   437     {
   370     _LIT( KTestName, "TimeoutTestCase" );
   438     _LIT( KTestName, "TimeoutTestCase" );
   371     iUnitTest->AddTestCaseL( 
   439     iUnitTest->AddTestCaseL( 
   372         KTestName, 
   440         KTestName, 
   373         CSymbianUnitTest::FunctionPtr( Dummy ), 
   441         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ), 
   374         CSymbianUnitTest::FunctionPtr( SimulateTimeoutL ), 
   442         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::SimulateTimeoutL ), 
   375         CSymbianUnitTest::FunctionPtr( Dummy ) );
   443         CSymbianUnitTest::FunctionPtr( &UT_CSymbianUnitTest::Dummy ) );
   376     //run test case without timeout control
   444     //run test case without timeout control
   377     iUnitTest->ExecuteL( *this, *iTestResult, ENoFailureSimulation, *iTestCaseNames, 0 );
   445     iUnitTest->ExecuteL( *this, *iTestResult, ENoFailureSimulation, *iTestCaseNames, 0 );
   378     SUT_ASSERT_EQUALS( 0, iTestResult->Failures().Count() )
   446     SUT_ASSERT_EQUALS( 0, iTestResult->Failures().Count() )
   379     SUT_ASSERT_EQUALS( 1, iExecutedTestCount )
   447     SUT_ASSERT_EQUALS( 1, iExecutedTestCount )
   380     //run test case with 3 seconds time out
   448     //run test case with 3 seconds time out
   397 //
   465 //
   398 // ---------------------------------------------------------------------------
   466 // ---------------------------------------------------------------------------
   399 //
   467 //
   400 void UT_CSymbianUnitTest::SimulatePanicL()
   468 void UT_CSymbianUnitTest::SimulatePanicL()
   401     {
   469     {
   402     HBufC* tmp( NULL );
   470     _LIT( KPanicString, "kkkkkkkkkkkk");
   403     tmp->Length();
   471     TBufC<3> buf( KPanicString );
   404     }
   472     }
   405 
   473 
   406 // ---------------------------------------------------------------------------
   474 // ---------------------------------------------------------------------------
   407 //
   475 //
   408 // ---------------------------------------------------------------------------
   476 // ---------------------------------------------------------------------------
   484 // ---------------------------------------------------------------------------
   552 // ---------------------------------------------------------------------------
   485 //
   553 //
   486 void UT_CSymbianUnitTest::Dummy()
   554 void UT_CSymbianUnitTest::Dummy()
   487     {
   555     {
   488     }
   556     }
       
   557 
       
   558 // ---------------------------------------------------------------------------
       
   559 //
       
   560 // ---------------------------------------------------------------------------
       
   561 //
       
   562 void UT_CSymbianUnitTest::SimulateEqualsAssertWithStringL()
       
   563 	{
       
   564 	_LIT( KSomeText, "some text" );
       
   565     AssertEqualsL( KSomeText, KSomeText, __LINE__, _L8( __FILE__ ) );	
       
   566 	}
       
   567 
       
   568 // ---------------------------------------------------------------------------
       
   569 //
       
   570 // ---------------------------------------------------------------------------
       
   571 //
       
   572 void UT_CSymbianUnitTest::SimulateEqualsAssertWithStringFailL()
       
   573 	{
       
   574 	_LIT( KSomeText, "some text" );
       
   575     AssertEqualsL( KNullDesC, KSomeText, __LINE__, _L8( __FILE__ ) );	
       
   576 	}
       
   577 
       
   578 // ---------------------------------------------------------------------------
       
   579 //
       
   580 // ---------------------------------------------------------------------------
       
   581 //
       
   582 void UT_CSymbianUnitTest::SimulateEqualsAssertWithString8L()
       
   583 	{
       
   584 	_LIT8( KSomeText, "some text" );
       
   585     AssertEqualsL( KSomeText, KSomeText, __LINE__, _L8( __FILE__ ) );	
       
   586 	}
       
   587 
       
   588 // ---------------------------------------------------------------------------
       
   589 //
       
   590 // ---------------------------------------------------------------------------
       
   591 //
       
   592 void UT_CSymbianUnitTest::SimulateEqualsAssertWithString8FailL()
       
   593 	{
       
   594 	_LIT8( KSomeText, "some text" );
       
   595     AssertEqualsL( KNullDesC8, KSomeText, __LINE__, _L8( __FILE__ ) );	
       
   596 	}
       
   597 	
       
   598 // ---------------------------------------------------------------------------
       
   599 //
       
   600 // ---------------------------------------------------------------------------
       
   601 //
       
   602 void UT_CSymbianUnitTest::SimulateEqualsAssertWithIntL()
       
   603 	{
       
   604 	const TInt KAssertValue(123);
       
   605 	AssertEqualsL( 123, KAssertValue, __LINE__, _L8( __FILE__ ) );	
       
   606 	}
       
   607 	
       
   608 // ---------------------------------------------------------------------------
       
   609 //
       
   610 // ---------------------------------------------------------------------------
       
   611 //
       
   612 void UT_CSymbianUnitTest::SimulateEqualsAssertWithIntFailL()
       
   613 	{
       
   614 	const TInt KAssertValue(123);
       
   615 	AssertEqualsL( -1, KAssertValue, __LINE__, _L8( __FILE__ ) );	
       
   616 	}