uifw/AvKon/tsrc/bc/bctestutil/inc/bctestassert.h
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2006-2007 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:  Assert tool for checking test result
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_CBCTESTASSERT_H
       
    20 #define C_CBCTESTASSERT_H
       
    21 
       
    22 #include <e32std.h>
       
    23 #include <e32base.h>
       
    24 
       
    25 class CBCTestLogger;
       
    26 
       
    27 /**
       
    28  *  CBCTestAssert
       
    29  */
       
    30 class CBCTestAssert: public CBase
       
    31     {    
       
    32 public: 
       
    33 
       
    34 // constructor and destructor
       
    35     
       
    36     /**
       
    37      * C++ default constructor.
       
    38      */
       
    39     IMPORT_C CBCTestAssert();
       
    40     
       
    41     /**
       
    42      * Destructor.
       
    43      */
       
    44     IMPORT_C virtual ~CBCTestAssert();
       
    45         
       
    46 // exported functions 
       
    47 
       
    48     /**
       
    49      * Assert tool functions. Using to verify the return value of tested API.
       
    50      * @param aExpect, the expected value.
       
    51      * @param aActual, the actual value.
       
    52      * @param aComments, one sentence of comments.
       
    53      */
       
    54     IMPORT_C void AssertIntL( TInt aExpect, TInt aActual, 
       
    55         const TDesC& aComments = KNullDesC );
       
    56         
       
    57     IMPORT_C void AssertTrueL( TBool aActual, 
       
    58         const TDesC& aComments = KNullDesC );
       
    59         
       
    60     IMPORT_C void AssertNotNullL( TAny* aActual, 
       
    61         const TDesC& aComments = KNullDesC );    
       
    62     
       
    63     /**
       
    64      * Write one sentence of log.
       
    65      * @param aLogText
       
    66      */
       
    67     IMPORT_C void WriteLogL( const TDesC& aLogText );
       
    68     
       
    69 // new functions
       
    70     
       
    71     /**
       
    72      * Set a pointer to logger.
       
    73      * @param aLogger, a pointer to a logger object.
       
    74      */
       
    75     void SetLogger( CBCTestLogger* aLogger );
       
    76     
       
    77     /**
       
    78      * Clear test statistic data. i.e. iTestCount and iFailedCount
       
    79      */
       
    80     void ClearTestSummary();
       
    81     
       
    82     /**
       
    83      * Get test statistic data.
       
    84      */    
       
    85     void GetTestSummary( TInt& aTestCount, TInt& aFailedCount ) const;
       
    86 
       
    87 protected:
       
    88 
       
    89 // declaration
       
    90     
       
    91     /**
       
    92      * The type of assert function.
       
    93      */
       
    94     enum TAssertType        
       
    95         {
       
    96         EAssertInt,
       
    97         EAssertTrue,
       
    98         EAssertNotNull,
       
    99         EAssertEnd
       
   100         };
       
   101     
       
   102     struct SAssertParam
       
   103         {
       
   104         TInt intValue;
       
   105         TAny* ptValue;        
       
   106         };
       
   107         
       
   108 // new functions
       
   109     
       
   110     /**
       
   111      * Wrtie log of assert result.
       
   112      * @param aType, what type of value has been checked.
       
   113      * @param aSuccess, whether the test passed.
       
   114      * @param aComments, comments about the assert.
       
   115      */
       
   116     void AssertLogL( TAssertType aType, TBool aSuccess, 
       
   117         const TDesC& aComments, SAssertParam* param = NULL );
       
   118         
       
   119 private: // data
       
   120     
       
   121     /**
       
   122      * Used to write log.
       
   123      * Not own.
       
   124      */
       
   125     CBCTestLogger* iLogger;
       
   126     
       
   127     /**
       
   128      * How many asserts failed totally.
       
   129      */
       
   130     TInt iFailedCount;
       
   131     
       
   132     /**
       
   133     * How many assert done totally.
       
   134     */
       
   135     TInt iTestCount;
       
   136     
       
   137     };
       
   138     
       
   139 #endif // C_CBCTESTASSERT_H