You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ne...@apache.org on 2017/05/02 17:28:23 UTC

mesos git commit: Added a test case for numify in stout.

Repository: mesos
Updated Branches:
  refs/heads/master 924bf54d2 -> 374a6a648


Added a test case for numify in stout.

Review: https://reviews.apache.org/r/58897


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

Branch: refs/heads/master
Commit: 374a6a648a38a2d04a11403c0d93f36c51e2830b
Parents: 924bf54
Author: Neil Conway <ne...@gmail.com>
Authored: Mon May 1 14:47:16 2017 -0700
Committer: Neil Conway <ne...@gmail.com>
Committed: Tue May 2 10:27:06 2017 -0700

----------------------------------------------------------------------
 3rdparty/stout/tests/numify_tests.cpp | 8 ++++++++
 1 file changed, 8 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/374a6a64/3rdparty/stout/tests/numify_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/tests/numify_tests.cpp b/3rdparty/stout/tests/numify_tests.cpp
index e28384a..a13807d 100644
--- a/3rdparty/stout/tests/numify_tests.cpp
+++ b/3rdparty/stout/tests/numify_tests.cpp
@@ -10,6 +10,8 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
+#include <limits>
+
 #include <gtest/gtest.h>
 
 #include <stout/gtest.hpp>
@@ -24,6 +26,12 @@ TEST(NumifyTest, DecNumberTest)
   Try<int> num2 = numify<int>("-10");
   EXPECT_SOME_EQ(-10, num2);
 
+  // `numify<T>` does not return an error if T is an unsigned integral
+  // type and the input is a negative number; rather, it returns the
+  // result of casting the numeric input value to T.
+  Try<unsigned int> num3 = numify<unsigned int>("-1");
+  EXPECT_SOME_EQ(std::numeric_limits<unsigned int>::max(), num3);
+
   EXPECT_ERROR(numify<unsigned int>(""));
   EXPECT_ERROR(numify<int>("-10."));
   EXPECT_ERROR(numify<unsigned int>("123xyz"));