Base module

TestRunner

Test manager queue.

#include <icy/test.h>

class TestRunner

Defined in src/base/include/icy/test.h:148

The TestRunner is a queue in charge of running one or many tests.

When run() the TestRunner loops through each test in the list calling the test's run() method.

Public Methods

ReturnNameDescription
TestRunner
~TestRunner virtual
voidaddAdds a test to the runner and prints its name to stdout.
Test *get constReturn a pointer to the test matching the given name, or nullptr if no matching test exists.
voidrunRuns all registered tests sequentially, printing results to stdout.
voidclearDestroy and clears all managed tests.
Test *current constReturn the currently active Test or nullptr.
TestListtests constReturn the list of tests.
ErrorMaperrors constReturn a map of tests and errors.
boolpassed constReturn true if all tests passed.

TestRunner

TestRunner()

Defined in src/base/include/icy/test.h:151


~TestRunner

virtual

virtual ~TestRunner()

Defined in src/base/include/icy/test.h:152


add

void add(Test * test)

Defined in src/base/include/icy/test.h:156

Adds a test to the runner and prints its name to stdout.

Parameters

ParameterTypeDescription
testTest *Non-null pointer to the test; the runner takes ownership.

get

const

Test * get(std::string_view name) const

Defined in src/base/include/icy/test.h:162

Return a pointer to the test matching the given name, or nullptr if no matching test exists.

Returns

Matching test pointer or nullptr.

Parameters

ParameterTypeDescription
namestd::string_viewTest name to search for.

run

void run()

Defined in src/base/include/icy/test.h:165

Runs all registered tests sequentially, printing results to stdout.


clear

void clear()

Defined in src/base/include/icy/test.h:168

Destroy and clears all managed tests.


current

const

Test * current() const

Defined in src/base/include/icy/test.h:171

Return the currently active Test or nullptr.


tests

const

TestList tests() const

Defined in src/base/include/icy/test.h:174

Return the list of tests.


errors

const

ErrorMap errors() const

Defined in src/base/include/icy/test.h:177

Return a map of tests and errors.


passed

const

bool passed() const

Defined in src/base/include/icy/test.h:180

Return true if all tests passed.

Public Static Methods

ReturnNameDescription
TestRunner &getDefault staticReturn the default TestRunner singleton, although TestRunner instances may also be initialized individually.

getDefault

static

static TestRunner & getDefault()

Defined in src/base/include/icy/test.h:184

Return the default TestRunner singleton, although TestRunner instances may also be initialized individually.

Protected Attributes

ReturnNameDescription
std::mutex_mutex
TestList_tests
Test *_current

_mutex

std::mutex _mutex

Defined in src/base/include/icy/test.h:187


_tests

TestList _tests

Type: TestList

Defined in src/base/include/icy/test.h:188


_current

Test * _current

Type: Test *

Defined in src/base/include/icy/test.h:189