You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ji...@apache.org on 2015/12/04 23:05:03 UTC
mesos git commit: Fixed comments for numify(),
cleaned up some test code.
Repository: mesos
Updated Branches:
refs/heads/master ec3a5423a -> fdfe2b55e
Fixed comments for numify(), cleaned up some test code.
Review: https://reviews.apache.org/r/40988
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/fdfe2b55
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/fdfe2b55
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/fdfe2b55
Branch: refs/heads/master
Commit: fdfe2b55ef71fb3abc066e2369f56d02cd6ba178
Parents: ec3a542
Author: Neil Conway <ne...@gmail.com>
Authored: Fri Dec 4 13:51:47 2015 -0800
Committer: Jie Yu <yu...@gmail.com>
Committed: Fri Dec 4 13:51:48 2015 -0800
----------------------------------------------------------------------
.../3rdparty/stout/include/stout/numify.hpp | 12 +++++++-----
.../3rdparty/stout/tests/numify_tests.cpp | 20 +++++++++++++-------
.../3rdparty/stout/tests/os_tests.cpp | 15 +++++----------
.../3rdparty/stout/tests/protobuf_tests.cpp | 3 +--
.../3rdparty/stout/tests/strings_tests.cpp | 13 ++++---------
5 files changed, 30 insertions(+), 33 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/fdfe2b55/3rdparty/libprocess/3rdparty/stout/include/stout/numify.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/numify.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/numify.hpp
index 322a899..26a637b 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/numify.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/numify.hpp
@@ -31,14 +31,16 @@ Try<T> numify(const std::string& s)
try {
return boost::lexical_cast<T>(s);
} catch (const boost::bad_lexical_cast&) {
- // Unfortunately boost::lexical_cast can not cast a hexadecimal
+ // Unfortunately boost::lexical_cast cannot cast a hexadecimal
// number even with a "0x" prefix, we have to workaround this
// issue here.
if (strings::startsWith(s, "0x") || strings::startsWith(s, "0X")) {
- // NOTE: The hexadecimal floating-point constants (e.g. 0x1p-5, 0x10.0),
- // which are allowed in the C99, but cannot be used as floating point
- // literals in standard C++, some C++ compilers might interpret them.
- // See: https://gcc.gnu.org/onlinedocs/gcc/Hex-Floats.html
+ // NOTE: Hexadecimal floating-point constants (e.g., 0x1p-5,
+ // 0x10.0), are allowed in C99, but cannot be used as floating
+ // point literals in standard C++. Some C++ compilers might
+ // accept them as an extension; for consistency, we always
+ // disallow them. See:
+ // https://gcc.gnu.org/onlinedocs/gcc/Hex-Floats.html
if (!strings::contains(s, ".") && !strings::contains(s, "p")) {
T result;
std::stringstream ss;
http://git-wip-us.apache.org/repos/asf/mesos/blob/fdfe2b55/3rdparty/libprocess/3rdparty/stout/tests/numify_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/tests/numify_tests.cpp b/3rdparty/libprocess/3rdparty/stout/tests/numify_tests.cpp
index 522fc34..444377d 100644
--- a/3rdparty/libprocess/3rdparty/stout/tests/numify_tests.cpp
+++ b/3rdparty/libprocess/3rdparty/stout/tests/numify_tests.cpp
@@ -18,10 +18,14 @@
TEST(NumifyTest, DecNumberTest)
{
- Try<unsigned int> num = numify<unsigned int>("10");
- ASSERT_SOME(num);
- EXPECT_EQ(10u, num.get());
+ Try<unsigned int> num1 = numify<unsigned int>("10");
+ EXPECT_SOME_EQ(10u, num1);
+ Try<int> num2 = numify<int>("-10");
+ EXPECT_SOME_EQ(-10, num2);
+
+ EXPECT_ERROR(numify<unsigned int>(""));
+ EXPECT_ERROR(numify<int>("-10."));
EXPECT_ERROR(numify<unsigned int>("123xyz"));
}
@@ -29,13 +33,15 @@ TEST(NumifyTest, DecNumberTest)
TEST(NumifyTest, HexNumberTest)
{
Try<unsigned int> num1 = numify<unsigned int>("0xdeadbeef");
- ASSERT_SOME(num1);
- EXPECT_EQ(0xdeadbeefu, num1.get());
+ EXPECT_SOME_EQ(0xdeadbeefu, num1);
Try<unsigned int> num2 = numify<unsigned int>("0x10");
- ASSERT_SOME(num2);
- EXPECT_EQ(16u, num2.get());
+ EXPECT_SOME_EQ(16u, num2);
+
+ // TODO(neilc): This is inconsistent with the handling of non-hex numbers.
+ EXPECT_ERROR(numify<int>("-0x10"));
+ EXPECT_ERROR(numify<unsigned int>(""));
EXPECT_ERROR(numify<unsigned int>("0xxyz"));
EXPECT_ERROR(numify<unsigned int>("abc"));
EXPECT_ERROR(numify<unsigned int>("0x0x1"));
http://git-wip-us.apache.org/repos/asf/mesos/blob/fdfe2b55/3rdparty/libprocess/3rdparty/stout/tests/os_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/tests/os_tests.cpp b/3rdparty/libprocess/3rdparty/stout/tests/os_tests.cpp
index fc5a821..743facd 100644
--- a/3rdparty/libprocess/3rdparty/stout/tests/os_tests.cpp
+++ b/3rdparty/libprocess/3rdparty/stout/tests/os_tests.cpp
@@ -179,14 +179,12 @@ TEST_F(OsTest, Nonblock)
Try<bool> isNonBlock = false;
isNonBlock = os::isNonblock(pipes[0]);
- ASSERT_SOME(isNonBlock);
- EXPECT_FALSE(isNonBlock.get());
+ EXPECT_SOME_FALSE(isNonBlock);
ASSERT_SOME(os::nonblock(pipes[0]));
isNonBlock = os::isNonblock(pipes[0]);
- ASSERT_SOME(isNonBlock);
- EXPECT_TRUE(isNonBlock.get());
+ EXPECT_SOME_TRUE(isNonBlock);
close(pipes[0]);
close(pipes[1]);
@@ -214,8 +212,7 @@ TEST_F(OsTest, ReadWriteString)
Try<string> readstr = os::read(testfile);
- ASSERT_SOME(readstr);
- EXPECT_EQ(teststr, readstr.get());
+ EXPECT_SOME_EQ(teststr, readstr);
}
@@ -363,13 +360,11 @@ TEST_F(OsTest, Sysctl)
Try<string> release = os::sysctl(CTL_KERN, KERN_OSRELEASE).string();
- ASSERT_SOME(release);
- EXPECT_EQ(uname.get().release, release.get());
+ EXPECT_SOME_EQ(uname.get().release, release);
Try<string> type = os::sysctl(CTL_KERN, KERN_OSTYPE).string();
- ASSERT_SOME(type);
- EXPECT_EQ(uname.get().sysname, type.get());
+ EXPECT_SOME_EQ(uname.get().sysname, type);
// Integer test.
Try<int> maxproc = os::sysctl(CTL_KERN, KERN_MAXPROC).integer();
http://git-wip-us.apache.org/repos/asf/mesos/blob/fdfe2b55/3rdparty/libprocess/3rdparty/stout/tests/protobuf_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/tests/protobuf_tests.cpp b/3rdparty/libprocess/3rdparty/stout/tests/protobuf_tests.cpp
index 7fa06a9..bf2a2b8 100644
--- a/3rdparty/libprocess/3rdparty/stout/tests/protobuf_tests.cpp
+++ b/3rdparty/libprocess/3rdparty/stout/tests/protobuf_tests.cpp
@@ -265,8 +265,7 @@ TEST(ProtobufTest, JsonLargeIntegers)
// Check String -> JSON.
Try<JSON::Object> json = JSON::parse<JSON::Object>(expected);
- ASSERT_SOME(json);
- EXPECT_EQ(object, json.get());
+ EXPECT_SOME_EQ(object, json);
}
http://git-wip-us.apache.org/repos/asf/mesos/blob/fdfe2b55/3rdparty/libprocess/3rdparty/stout/tests/strings_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/tests/strings_tests.cpp b/3rdparty/libprocess/3rdparty/stout/tests/strings_tests.cpp
index 7c0309c..7715fa4 100644
--- a/3rdparty/libprocess/3rdparty/stout/tests/strings_tests.cpp
+++ b/3rdparty/libprocess/3rdparty/stout/tests/strings_tests.cpp
@@ -32,22 +32,17 @@ using std::vector;
TEST(StringsTest, Format)
{
Try<std::string> result = strings::format("%s %s", "hello", "world");
- ASSERT_SOME(result);
- EXPECT_EQ("hello world", result.get());
+ EXPECT_SOME_EQ("hello world", result);
result = strings::format("hello %d", 42);
- ASSERT_SOME(result);
- EXPECT_EQ("hello 42", result.get());
+ EXPECT_SOME_EQ("hello 42", result);
result = strings::format("hello %s", "fourty-two");
- ASSERT_SOME(result);
- EXPECT_EQ("hello fourty-two", result.get());
+ EXPECT_SOME_EQ("hello fourty-two", result);
string hello = "hello";
-
result = strings::format("%s %s", hello, "fourty-two");
- ASSERT_SOME(result);
- EXPECT_EQ("hello fourty-two", result.get());
+ EXPECT_SOME_EQ("hello fourty-two", result);
}