Public Member Functions | Private Member Functions | Private Attributes

ut_Basic Class Reference
[Classes for unit tests]

#include <ut.h>

Collaboration diagram for ut_Basic:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ut_Basic (string a_testID, string a_testDescription, bool m_elapsedTime=false)
 ~ut_Basic ()
void Begin ()
 Begin method is used by constructor to write basic test header to stream.
void SetStatus (bool status)
 Set the status of basic test.

Private Member Functions

string Header (cmn_Time &currTime)
 Return all header information as string prepared to push into stream.

Private Attributes

const string m_testID
 m_TestID is created from: short lib name + short unit test name + number or basic test ID Short unit test name could be skipped if exist only one unit test per library.
const string m_testDescription
 Short description about basic test.
string m_spaceID
 space needed for fulfill testID read on 12 characters It's set in constructor
string m_spaceDes
 space needed for fulfill testDescription read on ut_DESCRIPTION_LEN characters It's set in constructor
bool m_status
 Result method set this member.
bool m_elapsedTime
 Calculate and put to cout of elapsed time in mili seconds.
cmn_Time m_start
cmn_Time m_end
 log_CLASSID_m
 Macro for class name member.

Detailed Description

Definition at line 507 of file ut.h.


Constructor & Destructor Documentation

ut_Basic::ut_Basic ( string  a_testID,
string  a_testDescription,
bool  m_elapsedTime = false 
)

Definition at line 69 of file ut_Basic.cpp.

References Begin(), ut_Group::GetLibName(), ut_Group::GetModulName(), ie_NULLPTR, m_spaceDes, m_spaceID, m_status, NULL, ut_currentUnitTest_p, ut_DESCRIPTION_LEN_c, and ut_TESTID_LEN_c.

                   : m_testID(a_testID),
                     m_testDescription(a_testDescription),
                     m_elapsedTime(a_elapsedTime),
                     m_start() {

    m_status = false;

    if (ut_currentUnitTest_p == NULL) {
        throw ivd_InternalError(ie_NULLPTR,
            "ut_Group object is not defined. ");
    }

    string libName   = ut_currentUnitTest_p->GetLibName();
    string modulName = ut_currentUnitTest_p->GetModulName();

    int spaceID = ut_TESTID_LEN_c - libName.length()
                                  - modulName.length()
                                  - a_testID.length() - 2; // two underlines between

    if (spaceID < 1) {
        spaceID = 1;
        m_spaceID = " ";
    }
    else {
        m_spaceID  = string(spaceID, ' ');
    }


    int spaceDes = ut_DESCRIPTION_LEN_c - a_testDescription.length();

    if (spaceDes < 1) {
        spaceDes = 1;
        m_spaceDes = " ";
    }
    else {
        m_spaceDes = string(spaceDes, ' ');
    }

    Begin();
}

Here is the call graph for this function:

ut_Basic::~ut_Basic (  ) 

Definition at line 113 of file ut_Basic.cpp.

References ut_Group::Failed(), ut_Group::GetStatus(), Header(), m_elapsedTime, m_end, m_start, m_status, cmn_Time::Time2hmsm(), ut_currentUnitTest_p, and ut_resultStream_g.

{
    cmn_Time currTime;
    m_end = currTime;

    if (m_elapsedTime) {
        currTime = currTime - m_start;
        ut_resultStream_g  << " Elapsed    " << currTime.Time2hmsm() << endl;
        cout << " Elapsed    " << currTime.Time2hmsm() << endl;
    }

    cout << Header(m_end);

    if (m_status) {
        ut_resultStream_g  <<  "[  OK  ] ";
        cout               <<  "[  OK  ] ";
    }
    else {
        ut_resultStream_g  <<  "[ FAIL ] ";
        cout               <<  "[ FAIL ] ";
        ut_currentUnitTest_p->Failed();
    }
    // show cumulative unit test status
    if (ut_currentUnitTest_p->GetStatus()) {
        ut_resultStream_g  <<  "[  OK  ]\n\n";
        cout               <<  "[  OK  ]\n\n";
    }
    else {
        ut_resultStream_g  <<  "[ FAIL ]\n\n";
        cout               <<  "[ FAIL ]\n\n";
    }
}

Here is the call graph for this function:


Member Function Documentation

void ut_Basic::Begin (  ) 

Begin method is used by constructor to write basic test header to stream.

Definition at line 159 of file ut_Basic.cpp.

References dbg_LOW, Header(), log_DBG_m, log_FUNCTAG_m, m_start, m_testID, and ut_resultStream_g.

Referenced by ut_Basic().

                     {
    log_FUNCTAG_m(Begin);

    ut_resultStream_g << Header(m_start);

    if (m_testID != "END") {
        cout << Header(m_start)
             <<  "[START ]" << endl;

        log_DBG_m(dbg_LOW, Header(m_start) << "[START ]");
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

string ut_Basic::Header ( cmn_Time currTime  )  [private]

Return all header information as string prepared to push into stream.

Definition at line 146 of file ut_Basic.cpp.

References ut_Group::GetLibName(), ut_Group::GetModulName(), m_spaceDes, m_spaceID, m_testDescription, m_testID, cmn_Time::Time2YMDhmsm(), and ut_currentUnitTest_p.

Referenced by Begin(), and ~ut_Basic().

                                          {
    ostringstream buf;

    buf << currTime.Time2YMDhmsm()              << " "
        << ut_currentUnitTest_p->GetLibName()   << "_"
        << ut_currentUnitTest_p->GetModulName() << "_"
        << m_testID                             << m_spaceID
        << m_testDescription                    << m_spaceDes;

    return buf.str();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void ut_Basic::SetStatus ( bool  status  ) 

Set the status of basic test.

If test is failed then method of ut_Group::SetStatus is invoked to set group test as failed.

See also:
ut_Group
ut_Group::SetStatus

Definition at line 172 of file ut_Basic.cpp.

References ut_Group::Failed(), m_status, and ut_currentUnitTest_p.

Referenced by ut_Group::Tail().

                                      {
    m_status = a_status;
    if (!a_status) {
        ut_currentUnitTest_p->Failed();
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Macro for class name member.

Definition at line 555 of file ut.h.

bool ut_Basic::m_elapsedTime [private]

Calculate and put to cout of elapsed time in mili seconds.

Definition at line 549 of file ut.h.

Referenced by ~ut_Basic().

Definition at line 552 of file ut.h.

Referenced by ~ut_Basic().

string ut_Basic::m_spaceDes [private]

space needed for fulfill testDescription read on ut_DESCRIPTION_LEN characters It's set in constructor

Definition at line 540 of file ut.h.

Referenced by Header(), and ut_Basic().

string ut_Basic::m_spaceID [private]

space needed for fulfill testID read on 12 characters It's set in constructor

Definition at line 534 of file ut.h.

Referenced by Header(), and ut_Basic().

Definition at line 551 of file ut.h.

Referenced by Begin(), and ~ut_Basic().

bool ut_Basic::m_status [private]

Result method set this member.

It is used by destructor to write OK or FAIL.

Definition at line 546 of file ut.h.

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

const string ut_Basic::m_testDescription [private]

Short description about basic test.

Only first

See also:
ut_DESCRIPTION_LEN characters will be written to ut_result file.

Definition at line 527 of file ut.h.

Referenced by Header().

const string ut_Basic::m_testID [private]

m_TestID is created from: short lib name + short unit test name + number or basic test ID Short unit test name could be skipped if exist only one unit test per library.

Definition at line 521 of file ut.h.

Referenced by Begin(), and Header().


The documentation for this class was generated from the following files: