ut_Basic Class Reference
[Classes for unit tests]

#include <ut.h>

Collaboration diagram for ut_Basic:

Collaboration graph
[legend]

List of all members.


Detailed Description

Definition at line 493 of file ut.h.


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.

Constructor & Destructor Documentation

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

Definition at line 55 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.

00058                    : m_testID(a_testID),
00059                      m_testDescription(a_testDescription),
00060                      m_elapsedTime(a_elapsedTime),
00061                      m_start() {
00062 
00063     m_status = false;
00064 
00065     if (ut_currentUnitTest_p == NULL) {
00066         throw ivd_InternalError(ie_NULLPTR,
00067             "ut_Group object is not defined. ");
00068     }
00069 
00070     string libName   = ut_currentUnitTest_p->GetLibName();
00071     string modulName = ut_currentUnitTest_p->GetModulName();
00072 
00073     int spaceID = ut_TESTID_LEN_c - libName.length()
00074                                   - modulName.length()
00075                                   - a_testID.length() - 2; // two underlines between
00076 
00077     if (spaceID < 1) {
00078         spaceID = 1;
00079         m_spaceID = " ";
00080     }
00081     else {
00082         m_spaceID  = string(spaceID, ' ');
00083     }
00084 
00085 
00086     int spaceDes = ut_DESCRIPTION_LEN_c - a_testDescription.length();
00087 
00088     if (spaceDes < 1) {
00089         spaceDes = 1;
00090         m_spaceDes = " ";
00091     }
00092     else {
00093         m_spaceDes = string(spaceDes, ' ');
00094     }
00095 
00096     Begin();
00097 }

Here is the call graph for this function:

ut_Basic::~ut_Basic (  ) 

Definition at line 99 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.

00100 {
00101     cmn_Time currTime;
00102     m_end = currTime;
00103 
00104     if (m_elapsedTime) {
00105         currTime = currTime - m_start;
00106         ut_resultStream_g  << " Elapsed    " << currTime.Time2hmsm() << endl;
00107         cout << " Elapsed    " << currTime.Time2hmsm() << endl;
00108     }
00109 
00110     cout << Header(m_end);
00111 
00112     if (m_status) {
00113         ut_resultStream_g  <<  "[  OK  ] ";
00114         cout               <<  "[  OK  ] ";
00115     }
00116     else {
00117         ut_resultStream_g  <<  "[ FAIL ] ";
00118         cout               <<  "[ FAIL ] ";
00119         ut_currentUnitTest_p->Failed();
00120     }
00121     // show cumulative unit test status
00122     if (ut_currentUnitTest_p->GetStatus()) {
00123         ut_resultStream_g  <<  "[  OK  ]\n\n";
00124         cout               <<  "[  OK  ]\n\n";
00125     }
00126     else {
00127         ut_resultStream_g  <<  "[ FAIL ]\n\n";
00128         cout               <<  "[ FAIL ]\n\n";
00129     }
00130 }

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 145 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().

00145                      {
00146     log_FUNCTAG_m(Begin);
00147 
00148     ut_resultStream_g << Header(m_start);
00149 
00150     if (m_testID != "END") {
00151         cout << Header(m_start)
00152              <<  "[START ]" << endl;
00153 
00154         log_DBG_m(dbg_LOW, Header(m_start) << "[START ]");
00155     }
00156 }

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 158 of file ut_Basic.cpp.

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

Referenced by ut_Group::Tail().

00158                                       {
00159     m_status = a_status;
00160     if (!a_status) {
00161         ut_currentUnitTest_p->Failed();
00162     }
00163 }

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 132 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().

00132                                           {
00133     ostringstream buf;
00134 
00135     buf << currTime.Time2YMDhmsm()              << " "
00136         << ut_currentUnitTest_p->GetLibName()   << "_"
00137         << ut_currentUnitTest_p->GetModulName() << "_"
00138         << m_testID                             << m_spaceID
00139         << m_testDescription                    << m_spaceDes;
00140 
00141     return buf.str();
00142 }

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

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 507 of file ut.h.

Referenced by Begin(), and Header().

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 513 of file ut.h.

Referenced by Header().

string ut_Basic::m_spaceID [private]

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

Definition at line 520 of file ut.h.

Referenced by Header(), and 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 526 of file ut.h.

Referenced by Header(), 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 532 of file ut.h.

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

bool ut_Basic::m_elapsedTime [private]

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

Definition at line 535 of file ut.h.

Referenced by ~ut_Basic().

Definition at line 537 of file ut.h.

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

Definition at line 538 of file ut.h.

Referenced by ~ut_Basic().

Macro for class name member.

Definition at line 541 of file ut.h.


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

Generated on Mon Feb 27 19:51:17 2012 for OPENARCHIVE by  doxygen 1.5.6