Go to the source code of this file.
Classes | |
class | UnitTestFailedException |
An exception thrown by unit test cases that fail. More... | |
class | UnitTestable |
Base class for unit testable classes. More... | |
class | UnitTest |
A collection of helper functions, for writing simple unit tests. More... | |
Macros | |
#define | UNITTESTS(class) void class::RunUnitTests(int& nSucceeded, int& nFailures) |
Helper for unit test case execution. More... | |
#define | UNITTEST(functionname) |
Helper for unit test case execution. More... | |
#define UNITTEST | ( | functionname | ) |
Helper for unit test case execution.
For each test case that throws a UnitTestFailedException, the number of failures is increased. For test cases that don't fail, the number of successful test cases is increased instead.
Usage: (usually at the end of a class implementation file)
#ifdef WITHUNITTESTS
static void MyClass::Test_MyClass_SomeTest() { UnitTest::Assert("expected blah blah", bool_condition); ... more asserts here ... }
...
UNITTESTS(MyClass) { UNITTEST(Test_MyClass_SomeTest); UNITTEST(Test_MyClass_AnotherTest); ... more test cases here ... }
#endif // WITHUNITTESTS
Note that MyClass (in the example above) should inherit from the UnitTestable class.
Definition at line 217 of file UnitTest.h.
Referenced by RootComponent::CheckVariableWrite(), EscapedString::Decode(), DYNTRANS_INSTR(), ComponentFactory::GetAllComponentNames(), DummyComponent::GetAttribute(), MachineComponent::GetAttribute(), CommandInterpreter::GetCurrentCommandBuffer(), QuitCommand::GetLongDescription(), ContinueBackwardsCommand::GetLongDescription(), VersionCommand::GetLongDescription(), CopyComponentCommand::GetLongDescription(), MoveComponentCommand::GetLongDescription(), PauseCommand::GetLongDescription(), ContinueCommand::GetLongDescription(), ResetCommand::GetLongDescription(), BackwardStepCommand::GetLongDescription(), StepCommand::GetLongDescription(), FileLoader::Load(), FileLoader_raw::LoadIntoComponent(), SymbolRegistry::LookupAddress(), Checksum::operator!=(), StateVariable::SetValue(), StringHelper::SplitStringIntoVector(), MainbusComponent::WriteData(), CPUComponent::WriteData(), CacheComponent::WriteData(), RAMComponent::WriteData(), and Command::~Command().
#define UNITTESTS | ( | class | ) | void class::RunUnitTests(int& nSucceeded, int& nFailures) |
Helper for unit test case execution.
The main purpose, appart from making the code look more compact, of having a macro for this is that the configure
script finds all .cc files that use this macro, and generates lists of header files to include and lists of RunUnitTests functions to call. These are then included and run from UnitTest::RunTests.
See the comment for UNITTEST for details on how to use it.
Definition at line 184 of file UnitTest.h.
Referenced by RootComponent::CheckVariableWrite(), EscapedString::Decode(), DYNTRANS_INSTR(), ComponentFactory::GetAllComponentNames(), DummyComponent::GetAttribute(), MachineComponent::GetAttribute(), CommandInterpreter::GetCurrentCommandBuffer(), QuitCommand::GetLongDescription(), ContinueBackwardsCommand::GetLongDescription(), VersionCommand::GetLongDescription(), CopyComponentCommand::GetLongDescription(), MoveComponentCommand::GetLongDescription(), PauseCommand::GetLongDescription(), ContinueCommand::GetLongDescription(), ResetCommand::GetLongDescription(), BackwardStepCommand::GetLongDescription(), StepCommand::GetLongDescription(), FileLoader::Load(), FileLoader_raw::LoadIntoComponent(), SymbolRegistry::LookupAddress(), Checksum::operator!=(), StateVariable::SetValue(), StringHelper::SplitStringIntoVector(), MainbusComponent::WriteData(), CPUComponent::WriteData(), CacheComponent::WriteData(), RAMComponent::WriteData(), and Command::~Command().