switched from using the << operator to the comma operator for all logging - this solves the problem in PR #431
diff --git a/examples/all_features/stringification.cpp b/examples/all_features/stringification.cpp
index abce6bb..d1118cc 100644
--- a/examples/all_features/stringification.cpp
+++ b/examples/all_features/stringification.cpp
@@ -77,6 +77,28 @@
// as a third option you may provide an overload of toString()
inline doctest::String toString(const Foo&) { return "Foo{}"; }
+
+struct MyStringType
+{
+ std::string s;
+ template <size_t N> MyStringType(const char (&in)[N]) : s(in, in + N) {}
+ friend bool operator==(const MyStringType &lhs, const MyStringType &rhs) { return lhs.s == rhs.s; }
+};
+
+// you can use the stream.write() method to write blocks of characters, and
+// you also can use a template operator<< if your code does not use
+// std::ostream and you'd like to avoid the include
+template <class OStream>
+OStream& operator<<(OStream& stream, const MyStringType& in) {
+ // the terminating \0 character may be present in size()
+ auto size = in.s.size() > 0u ? in.s.size() - 1u : 0u;
+ const char quote = '\'';
+ stream.write("e, 1u);
+ stream.write(in.s.data(), static_cast<unsigned>(size));
+ stream.write("e, 1u);
+ return stream;
+}
+
} // namespace Bar
// set an exception translator for MyTypeInherited<int>
@@ -127,6 +149,18 @@
CHECK(lst_1 == lst_2);
+ {
+ // use of ostream::write() is possible:
+ Bar::MyStringType s1 = "some";
+ Bar::MyStringType s2 = "contents";
+
+ // also inside the message builder
+ INFO("s1=", s1, " s2=", s2);
+
+ CHECK(s1 == s2);
+ CHECK_MESSAGE(s1 == s2, s1, " is not really ", s2);
+ }
+
// lets see if this exception gets translated
throw_if(true, bla1);
}