dodo  0.0.1
A C++ library to create containerized Linux services
dodo::common::UnitTest Class Referenceabstract

Unit test assitence class. More...

#include <unittest.hpp>

Collaboration diagram for dodo::common::UnitTest:

Public Member Functions

 UnitTest (const std::string &name, const std::string &description, std::ostream *out)
 Create a test. More...
 
virtual ~UnitTest ()
 Destructor. More...
 
bool run ()
 Run the test. More...
 

Protected Member Functions

virtual void doRun ()=0
 Virtual to implement the test. More...
 
bool writeSubTestResult (const std::string &name, const std::string &description, bool passed)
 Write the subtest result. More...
 

Private Member Functions

void writeUnitTestHeader ()
 Write the header. More...
 
void writeUnitTestSummary ()
 Write the summary. More...
 

Private Attributes

std::string description_
 The test description. More...
 
size_t failed_
 The total number of failed tests. More...
 
std::string name_
 The test name. More...
 
std::ostream * out_
 The output destination. More...
 
size_t total_
 The total number of tests. More...
 

Detailed Description

Unit test assitence class.

Definition at line 34 of file unittest.hpp.

Constructor & Destructor Documentation

◆ UnitTest()

dodo::common::UnitTest::UnitTest ( const std::string &  name,
const std::string &  description,
std::ostream *  out 
)

Create a test.

Parameters
nameThe name of the test.
descriptionThe description of the test.
outThe ostream to write to.

Definition at line 27 of file unittest.cpp.

◆ ~UnitTest()

virtual dodo::common::UnitTest::~UnitTest ( )
inlinevirtual

Destructor.

Definition at line 48 of file unittest.hpp.

Member Function Documentation

◆ doRun()

virtual void dodo::common::UnitTest::doRun ( )
protectedpure virtual

Virtual to implement the test.

Referenced by run().

Here is the caller graph for this function:

◆ run()

bool dodo::common::UnitTest::run ( )

Run the test.

Returns
True if the test passed.

Definition at line 35 of file unittest.cpp.

References doRun(), failed_, writeUnitTestHeader(), and writeUnitTestSummary().

Here is the call graph for this function:

◆ writeSubTestResult()

bool dodo::common::UnitTest::writeSubTestResult ( const std::string &  name,
const std::string &  description,
bool  passed 
)
protected

Write the subtest result.

Parameters
nameThe name of the test.
descriptionThe description of the test.
passedTrue if the test passed.
Returns
The value of parameter passed.

Definition at line 55 of file unittest.cpp.

References failed_, out_, and total_.

◆ writeUnitTestHeader()

void dodo::common::UnitTest::writeUnitTestHeader ( )
private

Write the header.

Definition at line 42 of file unittest.cpp.

References description_, name_, and out_.

Referenced by run().

Here is the caller graph for this function:

◆ writeUnitTestSummary()

void dodo::common::UnitTest::writeUnitTestSummary ( )
private

Write the summary.

Definition at line 49 of file unittest.cpp.

References failed_, out_, and total_.

Referenced by run().

Here is the caller graph for this function:

Field Documentation

◆ description_

std::string dodo::common::UnitTest::description_
private

The test description.

Definition at line 84 of file unittest.hpp.

Referenced by writeUnitTestHeader().

◆ failed_

size_t dodo::common::UnitTest::failed_
private

The total number of failed tests.

Definition at line 93 of file unittest.hpp.

Referenced by run(), writeSubTestResult(), and writeUnitTestSummary().

◆ name_

std::string dodo::common::UnitTest::name_
private

The test name.

Definition at line 81 of file unittest.hpp.

Referenced by writeUnitTestHeader().

◆ out_

std::ostream* dodo::common::UnitTest::out_
private

The output destination.

Definition at line 87 of file unittest.hpp.

Referenced by writeSubTestResult(), writeUnitTestHeader(), and writeUnitTestSummary().

◆ total_

size_t dodo::common::UnitTest::total_
private

The total number of tests.

Definition at line 90 of file unittest.hpp.

Referenced by writeSubTestResult(), and writeUnitTestSummary().


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