Pretty Printing Your TypesΒΆ

You can either provide an overloaded operato<< or specialize Enhedron::Assertion::Convert:

struct MyType {
    int x;
    int y;
};

namespace Enhedron { namespace Assertion {
    template<>
    struct Convert<MyType> {
        static string toString(const MyType& value) {
            ostringstream output;
            output << "{ x = " << value.x << ", y = " << value.y << " }";
            return output.str();
        }
    };
}}

The output of this:

given("an instance of MyType", [] (auto& check) {
    MyType myType{1, 2};
    check(VAR(myType.x) == 1, VAR(myType));
})

will now look like:

Then : (myType.x == 1)
        myType.x = 1: file "/work/build/MosquitoNet/cpp/test/src/Examples/AllExamples.cpp", line 258.
        myType = { x = 1, y = 2 }: file "/work/build/MosquitoNet/cpp/test/src/Examples/AllExamples.cpp", line 258.