UTPP
Loading...
Searching...
No Matches
utpp.h File Reference

Master include file. More...

#include <string>
#include <deque>
#include <stdexcept>
#include <sstream>
#include <cassert>
#include <sys/time.h>
#include <sys/stat.h>
#include <unistd.h>
#include "reporter_stream.h"
#include "reporter_xml.h"
#include "checks.h"

Go to the source code of this file.

Classes

class  UnitTest::Test
 Representation of a test case. More...
 
struct  UnitTest::Failure
 The failure object records the file name, the line number and a message. More...
 
class  UnitTest::Reporter
 Abstract base for all reporters. More...
 
class  UnitTest::ReporterDeferred
 A Reporter that keeps a list of test results. More...
 
struct  UnitTest::ReporterDeferred::TestResult
 Test results including all failure messages More...
 
class  UnitTest::TestSuite
 
class  UnitTest::TestSuite::Inserter
 Constructor of this objects inserts the test in suite. More...
 
class  UnitTest::Timer
 An object that can be interrogated to get elapsed time. More...
 
class  UnitTest::TimeConstraint
 Defines maximum run time of a test. More...
 
class  UnitTest::SuitesList
 A singleton object containing all test suites. More...
 
struct  UnitTest::test_abort
 Exception thrown by ABORT macro. More...
 
struct  UnitTest::tolerance_not_set
 

Macros

#define DEFAULT_SUITE   "DefaultSuite"
 Name of default suite.
 
#define _MSVC_LANG   __cplusplus
 
#define TEST_MAIN(ARGC, ARGV)
 
#define SUITE(Name)
 Declares the beginning of a new test suite.
 
#define TEST(Name)
 Defines a test case This macro must be followed by a code block containing the test.
 
#define TEST_FIXTURE(Fixture, Name)
 Defines a test case with an associated fixture.
 
#define ABORT(value)
 Abort current test if value is true. Abort message is the value itself.
 
#define ABORT_EX(value, ...)
 Abort current test if value is true. Outputs the given message.
 
#define UTPP_TIME_CONSTRAINT(ms)
 Defines a local (per scope) time constraint.
 
#define UTPP_TIME_CONSTRAINT_EXEMPT()
 Flags a test as not subject to the global time constraint.
 

Typedefs

typedef UnitTest::Test *(* UnitTest::Testmaker) ()
 Function pointer to a function that creates a test object.
 

Functions

void UnitTest::ReportFailure (const std::string &filename, int line, const std::string &message)
 Main error reporting function.
 
ReporterUnitTest::GetDefaultReporter ()
 Return the default reporter object.
 
int UnitTest::RunAllTests (Reporter &rpt=GetDefaultReporter(), int max_time_ms=0)
 Run all tests from all test suites.
 
void UnitTest::DisableSuite (const std::string &suite_name)
 Disable a test suite.
 
void UnitTest::EnableSuite (const std::string &suite_name)
 Enable a test suite.
 
int UnitTest::RunSuite (const char *suite_name, Reporter &rpt=GetDefaultReporter(), int max_time_ms=0)
 Run all tests from one suite.
 
void UnitTest::SleepMs (int const ms)
 Pause current thread for the specified time.
 
const char * GetSuiteName ()
 

Variables

const size_t UnitTest::MAX_MESSAGE_SIZE = 1024
 Maximum size of message buffer for ..._EX macro definitions.
 
TestUnitTest::CurrentTest
 Currently executing test.
 
std::string UnitTest::CurrentSuite
 Name of currently running suite.
 
ReporterUnitTest::CurrentReporter
 Pointer to current reporter object.
 

Detailed Description

Master include file.

This is the only header that users have to include. It takes care of pulling in all the other required headers.

Function Documentation

◆ GetSuiteName()

const char * GetSuiteName ( )
inline

Return current suite name for default suite. All other suites have the same function defined inside their namespaces.

◆ ReportFailure()

void UnitTest::ReportFailure ( const std::string & filename,
int line,
const std::string & message )
inline

Main error reporting function.

The function called by the various CHECK_... macros to record a failure.

Parameters
filenameName of file where the failure has occurred
lineLine number where the failure has occurred
messageFailure description

It calls the TestReporter::ReportFailure function of the current reporter object.