You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bm...@apache.org on 2016/07/01 21:13:06 UTC

[2/2] mesos git commit: Added comparison operator for Path in stout.

Added comparison operator for Path in stout.


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/16252d74
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/16252d74
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/16252d74

Branch: refs/heads/master
Commit: 16252d7449019b92e6ba9cd2d02a8436ccb3b430
Parents: 2a49ae2
Author: Benjamin Mahler <bm...@apache.org>
Authored: Fri Jul 1 14:10:35 2016 -0700
Committer: Benjamin Mahler <bm...@apache.org>
Committed: Fri Jul 1 14:12:12 2016 -0700

----------------------------------------------------------------------
 3rdparty/stout/include/stout/path.hpp | 36 ++++++++++++++++++++++++++++++
 3rdparty/stout/tests/path_tests.cpp   | 24 ++++++++++++++++++++
 2 files changed, 60 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/16252d74/3rdparty/stout/include/stout/path.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/path.hpp b/3rdparty/stout/include/stout/path.hpp
index 1b8326f..0ca13c6 100644
--- a/3rdparty/stout/include/stout/path.hpp
+++ b/3rdparty/stout/include/stout/path.hpp
@@ -254,6 +254,42 @@ public:
 };
 
 
+inline bool operator==(const Path& left, const Path& right)
+{
+  return left.value == right.value;
+}
+
+
+inline bool operator!=(const Path& left, const Path& right)
+{
+  return !(left == right);
+}
+
+
+inline bool operator<(const Path& left, const Path& right)
+{
+  return left.value < right.value;
+}
+
+
+inline bool operator>(const Path& left, const Path& right)
+{
+  return right < left;
+}
+
+
+inline bool operator<=(const Path& left, const Path& right)
+{
+  return !(left > right);
+}
+
+
+inline bool operator>=(const Path& left, const Path& right)
+{
+  return !(left < right);
+}
+
+
 inline std::ostream& operator<<(
     std::ostream& stream,
     const Path& path)

http://git-wip-us.apache.org/repos/asf/mesos/blob/16252d74/3rdparty/stout/tests/path_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/tests/path_tests.cpp b/3rdparty/stout/tests/path_tests.cpp
index 6dff5e7..8275e38 100644
--- a/3rdparty/stout/tests/path_tests.cpp
+++ b/3rdparty/stout/tests/path_tests.cpp
@@ -167,6 +167,30 @@ TEST(PathTest, Absolute)
 }
 
 
+TEST(PathTest, Comparison)
+{
+  EXPECT_TRUE(Path("a") == Path("a"));
+  EXPECT_FALSE(Path("a") == Path("b"));
+
+  EXPECT_TRUE(Path("a") != Path("b"));
+  EXPECT_FALSE(Path("a") != Path("a"));
+
+  EXPECT_TRUE(Path("a") < Path("b"));
+  EXPECT_FALSE(Path("b") < Path("a"));
+
+  EXPECT_TRUE(Path("a") <= Path("b"));
+  EXPECT_TRUE(Path("a") <= Path("a"));
+  EXPECT_FALSE(Path("b") <= Path("a"));
+
+  EXPECT_TRUE(Path("b") > Path("a"));
+  EXPECT_FALSE(Path("a") > Path("a"));
+
+  EXPECT_TRUE(Path("b") >= Path("a"));
+  EXPECT_TRUE(Path("b") >= Path("b"));
+  EXPECT_FALSE(Path("a") >= Path("b"));
+}
+
+
 class PathFileTest : public TemporaryDirectoryTest {};