Corrade::TestSuite::TestCaseDescriptionSourceLocation class new in Git master

Instanced test case description with source location.

When used instead of Containers::StringView or const char* to define instanced test case descriptions, any messages printed to the output will contain also the file/line info of where the instance data were defined in addition of file/line location from where the message originated:

const struct {
    TestSuite::TestCaseDescriptionSourceLocation name;
    const char* filename;
    const char* ext;
} ExtensionData[]{
    {"simple", "file.txt", ".txt"},
    {"no extension", "Documents", ""},
    {"two extensions", "data.tar.gz", ".tar.gz"},
    {"directory with a dot", "/etc/conf.d/samba", ""},

PathTest::PathTest() {

void PathTest::extension() {
    auto&& data = ExtensionData[testCaseInstanceId()];

    CORRADE_COMPARE(fileExtension(data.filename), data.ext);

Starting PathTest with 4 test cases...
    OK [1] extension(simple)
    OK [2] extension(no extension)
  FAIL [3] extension(two extensions) at …/PathTest.cpp:68 with data at …/PathTest.cpp:55
        Values fileExtension(data.filename) and data.ext are not the same, actual is
        but expected
    OK [4] extension(directory with a dot)
Finished PathTest with 1 errors out of 4 checks.

Useful especially in combination with terminals that are capable of treating the location information as a direct link to an IDE or text editor — clicking on …/PathTest.cpp:55 will open the editor at the line containing the "two extensions" test case instance.

At the moment, this feature is available on GCC at least since version 4.8 (although it may not be giving correct results until version 12), Clang 9+ and MSVC 2019 16.6 and newer. Elsewhere it behaves like if just a regular Tester::setTestCaseDescription(Containers::StringView) was used. You can check for its availability using the CORRADE_SOURCE_LOCATION_BUILTINS_SUPPORTED predefined macro.

Constructors, destructors, conversion operators

TestCaseDescriptionSourceLocation(Containers::StringView description)
TestCaseDescriptionSourceLocation(const char* description)

Function documentation

Corrade::TestSuite::TestCaseDescriptionSourceLocation::TestCaseDescriptionSourceLocation(const char* description)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.