You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2015/07/06 04:37:24 UTC
mesos git commit: MESOS-2965: Add implicit conversion from Path to
std::string.
Repository: mesos
Updated Branches:
refs/heads/master d69b10156 -> b8f2335ec
MESOS-2965: Add implicit conversion from Path to std::string.
Review: https://reviews.apache.org/r/36116
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/b8f2335e
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/b8f2335e
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/b8f2335e
Branch: refs/heads/master
Commit: b8f2335ecfbd171e0e5c039cebeaa3f2534a12e1
Parents: d69b101
Author: Joseph Wu <jo...@mesosphere.io>
Authored: Sun Jul 5 19:36:44 2015 -0700
Committer: Benjamin Hindman <be...@gmail.com>
Committed: Sun Jul 5 19:36:44 2015 -0700
----------------------------------------------------------------------
.../3rdparty/stout/include/stout/path.hpp | 6 +++++
.../3rdparty/stout/tests/path_tests.cpp | 27 ++++++++++++++++++++
2 files changed, 33 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/b8f2335e/3rdparty/libprocess/3rdparty/stout/include/stout/path.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/path.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/path.hpp
index a4afdad..86c12a5 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/path.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/path.hpp
@@ -101,6 +101,12 @@ public:
return value.substr(0, end + 1);
}
+ // Implicit conversion from Path to string.
+ operator std::string () const
+ {
+ return value;
+ }
+
const std::string value;
};
http://git-wip-us.apache.org/repos/asf/mesos/blob/b8f2335e/3rdparty/libprocess/3rdparty/stout/tests/path_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/tests/path_tests.cpp b/3rdparty/libprocess/3rdparty/stout/tests/path_tests.cpp
index 3211a0d..ad9ce32 100644
--- a/3rdparty/libprocess/3rdparty/stout/tests/path_tests.cpp
+++ b/3rdparty/libprocess/3rdparty/stout/tests/path_tests.cpp
@@ -18,6 +18,8 @@
#include <stout/path.hpp>
+#include <stout/tests/utils.hpp>
+
using std::string;
using std::vector;
@@ -117,3 +119,28 @@ TEST(PathTest, Join)
EXPECT_EQ("/a/b/c/", path::join("/a/", "/b/", "/c/"));
EXPECT_EQ("a/b/c/", path::join("a/", "/b/", "/c/"));
}
+
+
+class PathFileTest : public TemporaryDirectoryTest {};
+
+
+TEST_F(PathFileTest, ImplicitConversion)
+{
+ // Should be implicitly converted to string for the various os::_ calls.
+ const Path testfile(path::join(os::getcwd(), "file.txt"));
+
+ // Create the test file.
+ ASSERT_SOME(os::touch(testfile));
+ ASSERT_TRUE(os::exists(testfile));
+
+ // Open and close the file.
+ Try<int> fd = os::open(
+ testfile,
+ O_RDONLY,
+ S_IRUSR | S_IRGRP | S_IROTH);
+ ASSERT_SOME(fd);
+ close(fd.get());
+
+ // Delete the file.
+ EXPECT_SOME(os::rm(testfile));
+}