Sane C++ Libraries
C++ Platform Abstraction Libraries
Testing

🟨 Simple testing framework used by all of the other libraries

Testing is a very simple test framework that allows splitting tests in sections and record successful/failed expectations.

Features

Class Description
SC::TestCase A test case that can be split into multiple sections.
SC::TestReport Collects multiple TestCase and reports their results.

Status

🟨 MVP
Testing library is minimal but it's useful as is for now.

Description

Testing integrates with the SC::Result object that is part of Foundation library. So far it doesn't support test discovery and all tests must be manually invoked in the main test file.

SC::TestCase

A test case that can be split into multiple sections. To create a test case derive from SC::TestCase and run tests in the constructor

Example:

namespace SC
{
struct ConsoleTest;
}
struct SC::ConsoleTest : public SC::TestCase
{
ConsoleTest(SC::TestReport& report) : TestCase(report, "ConsoleTest")
{
using namespace SC;
SmallVector<char, 512 * sizeof(native_char_t)> consoleConversionBuffer;
Console console(consoleConversionBuffer);
if (test_section("print"))
{
String str = StringView("Test Test\n");
console.print(str.view());
}
}
};
namespace SC
{
void runConsoleTest(SC::TestReport& report) { ConsoleTest test(report); }
} // namespace SC
char native_char_t
The native char for the platform (wchar_t (4 bytes) on Windows, char (1 byte) everywhere else )
Definition: PrimitiveTypes.h:34
A test case that can be split into multiple sections.
Definition: Testing.h:69
bool test_section(StringView sectionName, Execute execution=Execute::Default)
Starts a new test section.
Collects multiple TestCase and reports their results.
Definition: Testing.h:25

SC::TestReport

Collects multiple TestCase and reports their results. This is passed as argument to SC::TestCase derived classes, and contains handle to globals like a console, paths to the library and application root, path to executable etc.

Roadmap

🟩 Usable

  • Test discovery

🟦 Complete Features:

  • IDE Integration

💡 Unplanned Features:

  • Template tests