testexecfw/symbianunittestfw/symbianunittestfw_pub/symbian_unit_test_api/inc/symbianunittestmacros.h
author Johnson Ma <johnson.ma@nokia.com>
Mon, 29 Mar 2010 14:46:27 +0800
changeset 1 bbd31066657e
parent 0 3e07fef1e154
permissions -rw-r--r--
publish symbianunittest v1.1.0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
     1
/*
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
     3
* All rights reserved.
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
     8
*
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
     9
* Initial Contributors:
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    11
*
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    12
* Contributors:
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    13
*
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    14
* Description:  
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    15
*
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    16
*/
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    17
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    18
#ifndef SYMBIANUNITTESTMACROS_H
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    19
#define SYMBIANUNITTESTMACROS_H
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    20
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    21
// INCLUDES
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    22
#include <e32std.h>
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    23
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    24
// MACROS
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    25
#ifdef SYMBIAN_UNIT_TEST
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    26
1
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
    27
    inline TInt operator==( TTrue, TInt aInt )
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
    28
        {
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
    29
        return aInt;
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
    30
        }
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
    31
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
    32
    inline TInt operator==( TInt aInt, TTrue )
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
    33
        {
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
    34
        return aInt;
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
    35
        }
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
    36
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
    37
    inline TInt operator!=( TTrue, TInt aInt )
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
    38
        {
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
    39
        return !aInt;
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
    40
        }
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
    41
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
    42
    inline TInt operator!=( TInt aInt, TTrue )
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
    43
        {
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
    44
        return !aInt;
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
    45
        }
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
    46
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
    47
    
0
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    48
    /** 
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    49
    * Calls the base class constructor that sets the name of unit test.
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    50
    */
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    51
    #define BASE_CONSTRUCT\
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    52
        CSymbianUnitTest::ConstructL( _L8( __PRETTY_FUNCTION__ ) );
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    53
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    54
    /**
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    55
    * Adds a new unit test case to this unit test.
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    56
    * The default setup and teardown functions will be used.
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    57
    * @param aTestPtr a function pointer to the unit test case
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    58
    */
1
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
    59
    #ifndef __GCCE__
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
    60
        #define ADD_SUT( aTestPtr )\
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
    61
            AddTestCaseL(\
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
    62
                _L( #aTestPtr ),\
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
    63
                CSymbianUnitTest::FunctionPtr( SetupL ),\
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
    64
                CSymbianUnitTest::FunctionPtr(aTestPtr),\
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
    65
                CSymbianUnitTest::FunctionPtr( Teardown ) );
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
    66
            
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
    67
    #else
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
    68
        #define ADD_SUT( aTestPtr )\
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
    69
            AddTestCaseL(\
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
    70
                _L( #aTestPtr ),\
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
    71
                CSymbianUnitTest::FunctionPtr( &CSymbianUnitTest::SetupL ),\
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
    72
                CSymbianUnitTest::FunctionPtr(&TYPE::aTestPtr),\
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
    73
                CSymbianUnitTest::FunctionPtr( &CSymbianUnitTest::Teardown ) );
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
    74
    #endif
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
    75
            
0
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    76
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    77
    /**
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    78
    * Adds a new unit test case to this unit test.
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    79
    * The user can specify
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    80
    * @param aSetupPtr a function pointer to the setup function 
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    81
    *        that will be executed before the actual unit test case
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    82
    * @param aTestPtr a function pointer to the unit test case
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    83
    * @param aTeardownPtr a function pointer to the teardown function
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    84
    *        that will be executed after the actual unit test case
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
    85
    */
1
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
    86
    #ifndef __GCCE__
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
    87
        #define ADD_SUT_WITH_SETUP_AND_TEARDOWN( aSetupPtr, aTestPtr, aTeardownPtr )\
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
    88
            AddTestCaseL(\
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
    89
                _L( #aTestPtr ),\
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
    90
                CSymbianUnitTest::FunctionPtr( aSetupPtr ),\
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
    91
                CSymbianUnitTest::FunctionPtr( aTestPtr ),\
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
    92
                CSymbianUnitTest::FunctionPtr( aTeardownPtr ) );
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
    93
     #else
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
    94
         #define ADD_SUT_WITH_SETUP_AND_TEARDOWN( aSetupPtr, aTestPtr, aTeardownPtr )\
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
    95
            AddTestCaseL(\
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
    96
                _L( #aTestPtr ),\
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
    97
                CSymbianUnitTest::FunctionPtr( &TYPE::aSetupPtr ),\
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
    98
                CSymbianUnitTest::FunctionPtr( &TYPE::aTestPtr ),\
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
    99
                CSymbianUnitTest::FunctionPtr( &TYPE::aTeardownPtr ) );
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
   100
     
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
   101
     #endif
0
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   102
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   103
    /**
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   104
    * Asserts a condition in a unit test case.
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   105
    * Leaves with a Symbian unit test framework specific error code
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   106
    * if the condition evaluates to EFalse.
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   107
    * In case of a failed assertion, the framework records 
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   108
    * the failure reason, line number and file name to the test results.
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   109
    * @param aCondition the asserted condition.
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   110
    */
1
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
   111
    
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
   112
       
0
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   113
    #define SUT_ASSERT( aCondition )\
1
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
   114
        if ( aCondition ) {} else\
0
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   115
            {\
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   116
            AssertionFailedL( _L8( #aCondition ), __LINE__, _L8( __FILE__ ) );\
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   117
            }
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   118
1
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
   119
   /**
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
   120
    * Asserts a condition in a unit test case.
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
   121
    * Leaves with a Symbian unit test framework specific error code
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
   122
    * if the condition evaluates to EFalse.
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
   123
    * In case of a failed assertion, the framework records 
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
   124
    * the failure reason, line number and file name to the test results.
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
   125
    * @param aCondition the asserted condition.
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
   126
    * @param aDescription the error description
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
   127
    */
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
   128
    
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
   129
       
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
   130
    #define SUT_ASSERT_DESC( aCondition, aDescription )\
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
   131
        if ( aCondition ) {} else\
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
   132
            {\
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
   133
            AssertionFailedL( _L8( aDescription ), __LINE__, _L8( __FILE__ ) );\
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
   134
            }
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
   135
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
   136
0
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   137
    /**
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   138
    * Asserts that two values are equal.
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   139
    * Leaves with a Symbian unit test framework specific error code
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   140
    * if the values are not equal.
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   141
    * In case of a failed assertion, the framework records 
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   142
    * the failure reason, line number and file name to the test results.
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   143
    * @param aExpectedValue the expected value
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   144
    * @param aActualValue the actual value
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   145
    */
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   146
    #define SUT_ASSERT_EQUALS( aExpected, aActual )\
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   147
        AssertEqualsL( aExpected, aActual, __LINE__, _L8( __FILE__ ) );
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   148
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   149
    /**
1
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
   150
    * Asserts that two values are equal.
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
   151
    * Leaves with a Symbian unit test framework specific error code
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
   152
    * if the values are not equal.
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
   153
    * In case of a failed assertion, the framework records 
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
   154
    * the failure reason, line number and file name to the test results.
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
   155
    * @param aExpectedValue the expected value
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
   156
    * @param aActualValue the actual value
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
   157
    * @param aDescription the error description
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
   158
    */
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
   159
    #define SUT_ASSERT_EQUALS_DESC( aExpected, aActual, aDescription )\
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
   160
        AssertEqualsL( aExpected, aActual, __LINE__, _L8( __FILE__ ), _L8(aDescription) );
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
   161
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
   162
    /**
0
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   163
    * Asserts that a statement leaves an expected value.
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   164
    * Leaves with a Symbian unit test framework specific error code
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   165
    * if the leave code is not the expected one.
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   166
    * In case of a failed assertion, the framework records 
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   167
    * the failure reason, line number and file name to the test results.
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   168
    * @param aStatement the statement
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   169
    * @param aError the expected leave code
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   170
    */
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   171
    #define SUT_ASSERT_LEAVE_WITH( aStatement, aError )\
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   172
        {\
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   173
        TInt KLine( __LINE__ );\
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   174
        TRAPD( err, aStatement )\
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   175
        AssertLeaveL( _L8( #aStatement ), err, aError, KLine, _L8( __FILE__ ) );\
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   176
        }
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   177
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   178
    /**
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   179
    * Asserts that a statement leaves.
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   180
    * The macro itself leaves with a Symbian unit test framework 
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   181
    * specific error code if the statement leaves.
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   182
    * In case of a failed assertion, the framework records 
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   183
    * the failure reason, the line number and file name to the test results.
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   184
    *
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   185
    * Note: SUT_ASSERT_LEAVE_WITH should be used instead 
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   186
    * whenever possible, because the implementation of 
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   187
    * SYMBIAN_UT_ASSERT_LEAVE TRAPs also KErrNoMemory.
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   188
    * This means that all the memory allocations are not looped through 
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   189
    * during the memory allocation failure simulation.
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   190
    * @param aStatement the statement
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   191
    */
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   192
    #define SUT_ASSERT_LEAVE( aStatement )\
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   193
        {\
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   194
        TInt KLine( __LINE__ );\
1
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
   195
        TRAPD( err, aStatement)\
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
   196
        if ( err==KErrNone )\
0
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   197
            {\
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   198
            RecordNoLeaveFromStatementL( _L8( #aStatement ), KLine, _L8( __FILE__ ) );\
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   199
            }\
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   200
        }
1
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
   201
        
0
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   202
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   203
    /**
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   204
    * Can be used to hide the friend declaration for a unit test class.
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   205
    */
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   206
    #define SYMBIAN_UNIT_TEST_CLASS( ClassName ) friend class ClassName;
1
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
   207
            
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
   208
    #define DEFINE_TEST_CLASS( aClassName )\
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
   209
        typedef aClassName TYPE;
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
   210
    
bbd31066657e publish symbianunittest v1.1.0
Johnson Ma <johnson.ma@nokia.com>
parents: 0
diff changeset
   211
    
0
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   212
#else 
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   213
    #define SYMBIAN_UNIT_TEST_CLASS( ClassName )
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   214
#endif // SYMBIAN_UNIT_TEST
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   215
3e07fef1e154 Initial EPL Contribution
Johnson Ma <johnson.ma@nokia.com>
parents:
diff changeset
   216
#endif // SYMBIANUNITTESTMACROS_H