4#include "../Foundation/Result.h"
5#include "../Strings/Console.h"
6#include "../Strings/StringView.h"
48 [[nodiscard]]
bool isTestEnabled(
StringView testName)
const;
49 [[nodiscard]]
bool isSectionEnabled(
StringView sectionName)
const;
51 void testCaseFinished(
TestCase& testCase);
52 void printSectionResult(
TestCase& testCase);
113#define SC_TEST_EXPECT(e) \
114 recordExpectation(StringView(#e##_a8), (e)) \
116 : (TestCase::report.debugBreakOnFailedTest ? SC_COMPILER_DEBUG_BREAK : (void)0)
unsigned int uint32_t
Platform independent (4) bytes unsigned int.
Definition: PrimitiveTypes.h:38
Writes to console using SC::StringFormat.
Definition: Console.h:27
An ascii string used as boolean result. SC_TRY macro forwards errors to caller.
Definition: Result.h:11
Non-owning view over a range of characters with UTF Encoding.
Definition: StringView.h:47
A test case that can be split into multiple sections.
Definition: Testing.h:69
bool recordExpectation(StringView expression, bool status, StringView detailedError=StringView())
Records an expectation for a given expression.
Execute
Definition: Testing.h:90
@ OnlyExplicit
Test is executed only if explicitly requested with –test-section.
@ Default
Test is executed if all tests are enabled or if this specific one matches –test-section.
TestReport & report
The TestReport object passed in the constructor.
Definition: Testing.h:101
TestCase(TestReport &report, StringView testName)
Adds this TestCase to a TestReport with a name.
bool test_section(StringView sectionName, Execute execution=Execute::Default)
Starts a new test section.
bool recordExpectation(StringView expression, Result status)
Records an expectation for a given expression.
Collects multiple TestCase and reports their results.
Definition: Testing.h:25
int getTestReturnCode() const
Gets return code for this process.
bool quietMode
If true will not print recaps at start or end of the test.
Definition: Testing.h:34
bool abortOnFirstFailedTest
If true will abort after first failed test.
Definition: Testing.h:32
TestReport(Console &console, int argc, const char **argv)
Build from a console and executable arguments.
StringView libraryRootDirectory
Path to sources directory for library.
Definition: Testing.h:27
bool debugBreakOnFailedTest
If true will issue a debugger halt when a test fails.
Definition: Testing.h:33
StringView executableFile
Path to current executable.
Definition: Testing.h:28
Console & console
The passed in console object where to print results.
Definition: Testing.h:26
StringView applicationRootDirectory
Path to application (on macOS is different from executable path)
Definition: Testing.h:29