diff --git a/include/turtle/matcher.hpp b/include/turtle/matcher.hpp index 7854d77..fc20a22 100644 --- a/include/turtle/matcher.hpp +++ b/include/turtle/matcher.hpp @@ -39,7 +39,12 @@ class matcher { public: explicit matcher(const char* expected) : expected_(expected) {} - bool operator()(const char* actual) { return std::strcmp(actual, expected_) == 0; } + bool operator()(const char* actual) + { + if (nullptr == actual || nullptr == expected_) + return actual == expected_; + return std::strcmp(actual, expected_) == 0; + } friend std::ostream& operator<<(std::ostream& s, const matcher& m) { return s << mock::format(m.expected_); } private: diff --git a/include/turtle/stream.hpp b/include/turtle/stream.hpp index 52991ed..e3bf273 100644 --- a/include/turtle/stream.hpp +++ b/include/turtle/stream.hpp @@ -106,7 +106,13 @@ namespace detail { { s << '"' << str << '"'; } - inline void serialize(stream& s, const char* const str) { s << '"' << str << '"'; } + inline void serialize(stream& s, const char* const str) + { + if (nullptr != str) + s << '"' << str << '"'; + else + s << "nullptr"; + } inline void serialize(stream& s, unsigned char c) { s << static_cast(c); } } // namespace detail } // namespace mock