From 3c5f6bd8ace79b3b23d69aa951825faa093a5507 Mon Sep 17 00:00:00 2001 From: "Daniel J. Hofmann" Date: Tue, 15 Mar 2016 13:59:19 +0100 Subject: [PATCH] Makes hint Equatable and Printable for tests --- include/engine/hint.hpp | 4 ++++ src/engine/hint.cpp | 13 ++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/include/engine/hint.hpp b/include/engine/hint.hpp index f74477c91..ece51f250 100644 --- a/include/engine/hint.hpp +++ b/include/engine/hint.hpp @@ -34,6 +34,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include +#include namespace osrm { @@ -57,6 +58,9 @@ struct Hint std::string ToBase64() const; static Hint FromBase64(const std::string &base64Hint); + + friend bool operator==(const Hint &, const Hint &); + friend std::ostream &operator<<(std::ostream &, const Hint &); }; #ifndef _MSC_VER diff --git a/src/engine/hint.cpp b/src/engine/hint.cpp index e24eabd4a..620670957 100644 --- a/src/engine/hint.cpp +++ b/src/engine/hint.cpp @@ -6,6 +6,8 @@ #include #include +#include +#include namespace osrm { @@ -45,5 +47,14 @@ Hint Hint::FromBase64(const std::string &base64Hint) return decodeBase64Bytewise(encoded); } + +bool operator==(const Hint &lhs, const Hint &rhs) +{ + return std::tie(lhs.phantom, lhs.data_checksum) == + std::tie(rhs.phantom, rhs.data_checksum); } -} + +std::ostream &operator<<(std::ostream &out, const Hint &hint) { return out << hint.ToBase64(); } + +} // ns engine +} // ns osrm