Corrade::TestSuite::Compare::File class

Pseudo-type for comparing file contents.

Prints the length of both files (if they are different) and prints the value and position of the first different character in both files. Filenames are expected to be in UTF-8. Example usage:

CORRADE_COMPARE_AS("actual.txt", "expected.txt", TestSuite::Compare::File);

If the files have the same path prefix, you can use CORRADE_COMPARE_WITH() and pass the prefix to the constructor:

CORRADE_COMPARE_WITH("actual.txt", "expected.txt",
    TestSuite::Compare::File{"/common/prefix"});

See Comparing with pseudo-types and Passing parameters to comparators for more information.

Saving files for failed comparisons

The comparator supports the --save-diagnostic option — if the comparison fails, it saves actual file contents to given directory with a filename matching the expected file. You can use it to perform a manual data comparison with an external tool or for example to quickly update expected test data — point the option to the directory with expected test files and let the test overwrite them with actual results. The StringToFile variant supports the same.

Constructors, destructors, conversion operators

File(Containers::StringView pathPrefix = {}) explicit
Constructor.

Function documentation

Corrade::TestSuite::Compare::File::File(Containers::StringView pathPrefix = {}) explicit

Constructor.

Parameters
pathPrefix Path prefix common for both files

See class documentation for more information.