You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by jo...@apache.org on 2016/10/14 23:47:19 UTC
[5/5] mesos git commit: Cleaned up style in stout rmdir_tests.cpp.
Cleaned up style in stout rmdir_tests.cpp.
Change a few test variables to `const` and made use of initializer lists
as these variables are only modified once at the beginning of the tests.
Review: https://reviews.apache.org/r/52848
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/99dfdf48
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/99dfdf48
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/99dfdf48
Branch: refs/heads/master
Commit: 99dfdf48c1aebb5ccc310edebcf59b4c84e6e810
Parents: 719f7c0
Author: Joseph Wu <jo...@apache.org>
Authored: Thu Oct 13 16:36:28 2016 -0700
Committer: Joseph Wu <jo...@apache.org>
Committed: Fri Oct 14 16:46:54 2016 -0700
----------------------------------------------------------------------
3rdparty/stout/tests/os/rmdir_tests.cpp | 33 ++++++++++++----------------
1 file changed, 14 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/99dfdf48/3rdparty/stout/tests/os/rmdir_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/tests/os/rmdir_tests.cpp b/3rdparty/stout/tests/os/rmdir_tests.cpp
index e19a508..cd46336 100644
--- a/3rdparty/stout/tests/os/rmdir_tests.cpp
+++ b/3rdparty/stout/tests/os/rmdir_tests.cpp
@@ -54,15 +54,15 @@ class RmdirTest : public TemporaryDirectoryTest {};
TEST_F(RmdirTest, TrivialRemoveEmptyDirectoryAbsolutePath)
{
const string tmpdir = os::getcwd();
- hashset<string> expectedListing = hashset<string>::EMPTY;
// Directory is initially empty.
- EXPECT_EQ(expectedListing, listfiles(tmpdir));
+ EXPECT_EQ(hashset<string>::EMPTY, listfiles(tmpdir));
// Successfully make directory using absolute path.
const string newDirectoryName = "newDirectory";
const string newDirectoryAbsolutePath = path::join(tmpdir, newDirectoryName);
- expectedListing.insert(newDirectoryName);
+ const hashset<string> expectedListing = { newDirectoryName };
+
EXPECT_SOME(os::mkdir(newDirectoryAbsolutePath));
EXPECT_EQ(expectedListing, listfiles(tmpdir));
EXPECT_EQ(hashset<string>::EMPTY, listfiles(newDirectoryAbsolutePath));
@@ -76,14 +76,14 @@ TEST_F(RmdirTest, TrivialRemoveEmptyDirectoryAbsolutePath)
TEST_F(RmdirTest, TrivialRemoveEmptyDirectoryRelativePath)
{
const string tmpdir = os::getcwd();
- hashset<string> expectedListing = hashset<string>::EMPTY;
// Directory is initially empty.
- EXPECT_EQ(expectedListing, listfiles(tmpdir));
+ EXPECT_EQ(hashset<string>::EMPTY, listfiles(tmpdir));
// Successfully make directory using relative path.
const string newDirectoryName = "newDirectory";
- expectedListing.insert(newDirectoryName);
+ const hashset<string> expectedListing = { newDirectoryName };
+
EXPECT_SOME(os::mkdir(newDirectoryName));
EXPECT_EQ(expectedListing, listfiles(tmpdir));
EXPECT_EQ(hashset<string>::EMPTY, listfiles(newDirectoryName));
@@ -98,11 +98,9 @@ TEST_F(RmdirTest, TrivialRemoveEmptyDirectoryRelativePath)
TEST_F(RmdirTest, RemoveFile)
{
const string tmpdir = os::getcwd();
- hashset<string> expectedRootListing = hashset<string>::EMPTY;
- hashset<string> expectedSubListing = hashset<string>::EMPTY;
// Directory is initially empty.
- EXPECT_EQ(expectedRootListing, listfiles(tmpdir));
+ EXPECT_EQ(hashset<string>::EMPTY, listfiles(tmpdir));
// Successfully make directory using absolute path, and then `touch` a file
// in that folder.
@@ -113,8 +111,8 @@ TEST_F(RmdirTest, RemoveFile)
newDirectoryAbsolutePath,
newFileName);
- expectedRootListing.insert(newDirectoryName);
- expectedSubListing.insert(newFileName);
+ const hashset<string> expectedRootListing = { newDirectoryName };
+ const hashset<string> expectedSubListing = { newFileName };
EXPECT_SOME(os::mkdir(newDirectoryAbsolutePath));
EXPECT_SOME(os::touch(newFileAbsolutePath));
@@ -156,11 +154,9 @@ TEST_F(RmdirTest, RemoveFile)
TEST_F(RmdirTest, RemoveRecursiveByDefault)
{
const string tmpdir = os::getcwd();
- hashset<string> expectedRootListing = hashset<string>::EMPTY;
- hashset<string> expectedSubListing = hashset<string>::EMPTY;
// Directory is initially empty.
- EXPECT_EQ(expectedRootListing, listfiles(tmpdir));
+ EXPECT_EQ(hashset<string>::EMPTY, listfiles(tmpdir));
// Successfully make directory using absolute path, and then `touch` a file
// in that folder.
@@ -171,8 +167,8 @@ TEST_F(RmdirTest, RemoveRecursiveByDefault)
newDirectoryAbsolutePath,
newFileName);
- expectedRootListing.insert(newDirectoryName);
- expectedSubListing.insert(newFileName);
+ const hashset<string> expectedRootListing = { newDirectoryName };
+ const hashset<string> expectedSubListing = { newFileName };
EXPECT_SOME(os::mkdir(newDirectoryAbsolutePath));
EXPECT_SOME(os::touch(newFileAbsolutePath));
@@ -203,16 +199,15 @@ TEST_F(RmdirTest, TrivialFailToRemoveInvalidPath)
TEST_F(RmdirTest, FailToRemoveNestedInvalidPath)
{
const string tmpdir = os::getcwd();
- hashset<string> expectedRootListing = hashset<string>::EMPTY;
// Directory is initially empty.
- EXPECT_EQ(expectedRootListing, listfiles(tmpdir));
+ EXPECT_EQ(hashset<string>::EMPTY, listfiles(tmpdir));
// Successfully make directory using absolute path.
const string newDirectoryName = "newDirectory";
const string newDirectoryAbsolutePath = path::join(tmpdir, newDirectoryName);
- expectedRootListing.insert(newDirectoryName);
+ const hashset<string> expectedRootListing = { newDirectoryName };
EXPECT_SOME(os::mkdir(newDirectoryAbsolutePath));
EXPECT_EQ(expectedRootListing, listfiles(tmpdir));