Repository: mesos Updated Branches: refs/heads/master b2877c106 -> 777d36240
Added equality operators for http::Pipe. See: MESOS-3162. This is useful for checking connection equality. Note that this is the same as Future, where Future is a shared object: copies are considered equal. Review: https://reviews.apache.org/r/36898 Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/777d3624 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/777d3624 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/777d3624 Branch: refs/heads/master Commit: 777d362402781a09220bc29b9f1478fff8522e9b Parents: b2877c1 Author: Benjamin Mahler <[email protected]> Authored: Tue Jul 28 15:43:25 2015 -0700 Committer: Benjamin Mahler <[email protected]> Committed: Tue Jul 28 15:44:47 2015 -0700 ---------------------------------------------------------------------- 3rdparty/libprocess/include/process/http.hpp | 12 ++++++++++++ 3rdparty/libprocess/src/tests/http_tests.cpp | 20 ++++++++++++++++++++ 2 files changed, 32 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/777d3624/3rdparty/libprocess/include/process/http.hpp ---------------------------------------------------------------------- diff --git a/3rdparty/libprocess/include/process/http.hpp b/3rdparty/libprocess/include/process/http.hpp index 9faed55..b8d9300 100644 --- a/3rdparty/libprocess/include/process/http.hpp +++ b/3rdparty/libprocess/include/process/http.hpp @@ -179,6 +179,10 @@ public: // interested. Returns false if the read-end was already closed. bool close(); + // Comparison operators useful for checking connection equality. + bool operator == (const Reader& other) const { return data == other.data; } + bool operator != (const Reader& other) const { return !(*this == other); } + private: friend class Pipe; @@ -216,6 +220,10 @@ public: // was unable to continue reading! Future<Nothing> readerClosed(); + // Comparison operators useful for checking connection equality. + bool operator == (const Writer& other) const { return data == other.data; } + bool operator != (const Writer& other) const { return !(*this == other); } + private: friend class Pipe; @@ -236,6 +244,10 @@ public: Reader reader() const; Writer writer() const; + // Comparison operators useful for checking connection equality. + bool operator == (const Pipe& other) const { return data == other.data; } + bool operator != (const Pipe& other) const { return !(*this == other); } + private: struct Data { http://git-wip-us.apache.org/repos/asf/mesos/blob/777d3624/3rdparty/libprocess/src/tests/http_tests.cpp ---------------------------------------------------------------------- diff --git a/3rdparty/libprocess/src/tests/http_tests.cpp b/3rdparty/libprocess/src/tests/http_tests.cpp index 01f243c..ecbcbd5 100644 --- a/3rdparty/libprocess/src/tests/http_tests.cpp +++ b/3rdparty/libprocess/src/tests/http_tests.cpp @@ -515,6 +515,26 @@ TEST(HTTPTest, StreamingGetFailure) } +TEST(HTTPTest, PipeEquality) +{ + // Pipes are shared objects, like Futures. Copies are considered + // equal as they point to the same underlying object. + http::Pipe pipe1; + http::Pipe copy = pipe1; + + EXPECT_EQ(pipe1, copy); + + http::Pipe pipe2; + EXPECT_NE(pipe2, pipe1); + + EXPECT_EQ(pipe1.reader(), pipe1.reader()); + EXPECT_EQ(pipe1.writer(), pipe1.writer()); + + EXPECT_NE(pipe1.reader(), pipe2.reader()); + EXPECT_NE(pipe1.writer(), pipe2.writer()); +} + + http::Response validatePost(const http::Request& request) { EXPECT_EQ("POST", request.method);
