Classes for unit tests
[Common modules]

Collaboration diagram for Classes for unit tests:


Classes

class  ut_Group
 Class that hold identification of particular unit tests, it's used by ut_Basic class. More...
class  ut_Basic

Defines

#define ivd_UT_MATCH_X_m(A, B)
 Different macroes for unit test classes.
#define ivd_UT_NOTMATCH_X_m(A, B, COMMENT)
#define ivd_UT_MATCH_A_m(A, B)
#define ivd_UT_MATCH_m(A, B)
#define ivd_UT_MATCH_COMM_m(A, B, COMMENT)
#define ivd_UT_COMPARE_m(MEM)
#define ivd_UT_COMPARE_S_m(MEM)
#define ivd_UT_COMPARE_AB_m(A, B)
#define ivd_UT_COMPARE_BC_m(BASE_CLASS)
#define ivd_UT_COMPARE_PTR_VAL_m(TYPE, MEM)
#define ivd_UT_COMPARE_VAL_m(UT_TYPE, MEM)
#define ivd_UT_COMPARE_PTR_m(UT_TYPE, MEM)
#define ivd_UT_COMPARE_ARR_m(TYPE, SIZEO, SIZES, MEM)
#define ivd_UT_COMPARE_VEC_m(TYPE, MEM)
#define ivd_UT_COMPARE_VEC_OF_PTR_m(UT_TYPE, VEC_TYPE, MEM)
#define ut_GROUP_m(_libName, _modName, _header, _text)
#define ut_BELAP_m(_testID, _text, _elapsedTime)
 Class that hold information about basic (elementary) unit test.
#define ut_BASIC_m(_testID, _text)

Functions

IVD_UT_DECL_d Int64_t Rand (Int64_t to=RAND_MAX, Int64_t from=0)
void ut_CompareHeaderOutput_On ()
void ut_CompareHeaderOutput_Off ()
void ut_ClassNameComment (const string &a_className)

Variables

stx_Stream ut_resultStream_g
 Stream that store unit result to file "ut_result" on current directory.
ut_Grouput_currentUnitTest_p
 Pointer to current unit test group.
const unsigned int ut_DESCRIPTION_LEN_c
 Maximum length of basic test description.
const unsigned int ut_TESTID_LEN_c
 Maximum length of basic test identification (testID) concatenate with library name, module name, and test ID.
bool ut_compareHeaderOutput_g


Define Documentation

#define ivd_UT_COMPARE_AB_m ( A,
 ) 

Value:

if ((A) != (B)) {                           \
        ret = false;                            \
        cout << "    " << #A << " != " #B  << " "         \
             << (A) << " != " << (B) << endl;   \
    }

Definition at line 86 of file ut.h.

#define ivd_UT_COMPARE_ARR_m ( TYPE,
SIZEO,
SIZES,
MEM   ) 

Definition at line 155 of file ut.h.

#define ivd_UT_COMPARE_BC_m ( BASE_CLASS   ) 

Value:

const BASE_CLASS &obj = *static_cast<const BASE_CLASS*>(&tObj);    \
    const ut_##BASE_CLASS &sam = *static_cast<const ut_##BASE_CLASS*>( \
            static_cast<const BASE_CLASS*>(this)); \
    if (sam != obj) {   \
        ret = false;    \
    }

Definition at line 93 of file ut.h.

#define ivd_UT_COMPARE_m ( MEM   ) 

Value:

if (MEM != tObj.MEM) {             \
            cout << "    " << s_className << "::" << #MEM  \
                 << " " << tObj.MEM            \
                 << " != " << MEM << endl;      \
            ret = false;                                \
    };

Definition at line 68 of file ut.h.

#define ivd_UT_COMPARE_PTR_m ( UT_TYPE,
MEM   ) 

Value:

{ \
    if (ut_compareHeaderOutput_g) \
        cout << "  Compare prt of type " << #UT_TYPE  \
             << " " << s_className << "::" << #MEM  << endl;\
    void *a(MEM);                               \
    void *b(tObj.MEM);                          \
    if (   a == NULL && b != NULL               \
        || a != NULL && b == NULL) {            \
        cout << "    " << s_className << "::" << #MEM     \
            << " " << tObj.MEM                       \
            << " != " << MEM << endl;      \
        ret = false;                            \
    }                                           \
    else if (a != NULL) {                       \
        if (!(*static_cast<UT_TYPE*>(MEM) == *tObj.MEM)) {      \
            ret = false;                                        \
        }                                                       \
    } \
}

Definition at line 134 of file ut.h.

#define ivd_UT_COMPARE_PTR_VAL_m ( TYPE,
MEM   ) 

Value:

{ \
    if (ut_compareHeaderOutput_g) \
        cout << "  Compare prt val " << s_className << "::" << #MEM  << endl;\
    const TYPE *a = MEM;                              \
    const TYPE *b = tObj.MEM;                         \
    if (   a == NULL && b != NULL               \
        || a != NULL && b == NULL) {            \
        cout << "    " << s_className << "::" << #MEM     \
            << " " << tObj.MEM                       \
            << " != " << MEM << endl;      \
        ret = false;                            \
    }                                           \
    else if (a != NULL) {                       \
        if ((*MEM) != *tObj.MEM) {      \
            cout << "    *" << s_className << "::" << #MEM  \
                 << " " << *tObj.MEM            \
                 << " != " << *MEM << endl;      \
            ret = false;                                        \
        }                                                       \
    }   \
}

Definition at line 101 of file ut.h.

#define ivd_UT_COMPARE_S_m ( MEM   ) 

Value:

if (MEM != tObj.MEM) {             \
            cout << "    " << s_className << "::" << #MEM  \
                 << " '" << tObj.MEM            \
                 << "' != '" << MEM << "'" << endl;      \
            ret = false;                                \
    };

Definition at line 77 of file ut.h.

#define ivd_UT_COMPARE_VAL_m ( UT_TYPE,
MEM   ) 

Value:

{ \
    const UT_TYPE &sam = *static_cast<const UT_TYPE*>(&MEM); \
    if (sam != tObj.MEM) {      \
        cout << "  Member(s) of " << s_className << "::" << #MEM  \
             << " doesn't match" << endl;              \
        ret = false;                                   \
    }                                                  \
}

Definition at line 124 of file ut.h.

#define ivd_UT_COMPARE_VEC_m ( TYPE,
MEM   ) 

Definition at line 238 of file ut.h.

#define ivd_UT_COMPARE_VEC_OF_PTR_m ( UT_TYPE,
VEC_TYPE,
MEM   ) 

Definition at line 313 of file ut.h.

#define ivd_UT_MATCH_A_m ( A,
 ) 

Value:

if ((A) != (B)) {                           \
        match = false;                          \
        cout << #A <<  "; "                     \
             << (A) << " != " << (B) << endl;   \
    }

Definition at line 44 of file ut.h.

#define ivd_UT_MATCH_COMM_m ( A,
B,
COMMENT   ) 

Value:

if ((A) != (B)) {                           \
        match = false;                          \
        cout << #A << " != " #B  << "; "        \
             << (A) << " != " << (B)            \
             << "; " << COMMENT << endl;         \
    }

Definition at line 60 of file ut.h.

#define ivd_UT_MATCH_m ( A,
 ) 

Value:

if ((A) != (B)) {                           \
        match = false;                          \
        cout << #A << " != " #B  << "; "        \
             << (A) << " != " << (B) << endl;   \
    }

Definition at line 52 of file ut.h.

#define ivd_UT_MATCH_X_m ( A,
 ) 

Value:

if ((A) != (B)) {                           \
        match = false;                          \
    }
Different macroes for unit test classes.

Definition at line 30 of file ut.h.

#define ivd_UT_NOTMATCH_X_m ( A,
B,
COMMENT   ) 

Value:

if ((A) == (B)) {                           \
        match = false;                          \
    }                                           \
    else {                                      \
        cout << "OK! " << COMMENT << endl;      \
    }

Definition at line 35 of file ut.h.

#define ut_BASIC_m ( _testID,
_text   ) 

Value:

ostringstream sStr; \
        sStr << _text; \
        ut_Basic basict(_testID, sStr.str());

Definition at line 488 of file ut.h.

#define ut_BELAP_m ( _testID,
_text,
_elapsedTime   ) 

Value:

ostringstream sStr; \
        sStr << _text; \
        ut_Basic basict(_testID, sStr.str(), _elapsedTime);
Class that hold information about basic (elementary) unit test.

It use functionality of ut_Group class that is singleton and is instantiate in ut_Group.cpp file as ut_Group_g.

Example:

    ut_Group fileioTest("fileio");
    {   ut_Basic basict("0002", "Seek end of file");
        ...
        succeed  = <some expresion>;
        basict.SetStatus(succeed);
    }

Definition at line 483 of file ut.h.

#define ut_GROUP_m ( _libName,
_modName,
_header,
_text   ) 

Value:

ostringstream sStr; \
        sStr << _text; \
        ut_Group groupTest(_libName, _modName, _header, sStr.str());

Definition at line 358 of file ut.h.


Function Documentation

IVD_UT_DECL_d Int64_t Rand ( Int64_t  to = RAND_MAX,
Int64_t  from = 0 
)

Definition at line 38 of file ut_Group.cpp.

00038                                        {
00039     Int64_t diff = to - from + 1; // number of different numbers
00040     return ((Int64_t)rand() * diff) / (RAND_MAX + 1LL) + from;
00041 }

void ut_ClassNameComment ( const string &  a_className  ) 

Definition at line 47 of file ut_Group.cpp.

00047                                                     {
00048     string s(string("Test of class ") + a_className);
00049     cout
00050         << s << endl
00051          << string(s.length(), '=') << endl;
00052 }

void ut_CompareHeaderOutput_Off (  ) 

Definition at line 46 of file ut_Group.cpp.

References ut_compareHeaderOutput_g.

00046 {ut_compareHeaderOutput_g = false;}

void ut_CompareHeaderOutput_On (  ) 

Definition at line 45 of file ut_Group.cpp.

References ut_compareHeaderOutput_g.

00045 {ut_compareHeaderOutput_g = true;}


Variable Documentation

Definition at line 43 of file ut_Group.cpp.

Referenced by ut_CompareHeaderOutput_Off(), and ut_CompareHeaderOutput_On().

Pointer to current unit test group.

Pointer to current unit test group.

It is used by ut_Basic::Result method to set

Definition at line 60 of file ut_Group.cpp.

Referenced by ut_Basic::Header(), ut_Basic::SetStatus(), ut_Basic::ut_Basic(), and ut_Basic::~ut_Basic().

const unsigned int ut_DESCRIPTION_LEN_c

Maximum length of basic test description.

Definition at line 43 of file ut_Basic.cpp.

Referenced by ut_Group::Header(), and ut_Basic::ut_Basic().

Stream that store unit result to file "ut_result" on current directory.

Referenced by ut_Basic::Begin(), ut_Group::Init(), ut_Basic::~ut_Basic(), and ut_Group::~ut_Group().

const unsigned int ut_TESTID_LEN_c

Maximum length of basic test identification (testID) concatenate with library name, module name, and test ID.

See also:
ut_Basic::m_testID

ut_Group::m_libName

ut_Group::m_modulName

Definition at line 44 of file ut_Basic.cpp.

Referenced by ut_Group::Header(), and ut_Basic::ut_Basic().


Generated on Mon Feb 27 18:55:22 2012 for OPENARCHIVE by  doxygen 1.5.6