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 2012/09/10 00:03:17 UTC

svn commit: r1382593 - /incubator/mesos/trunk/src/tests/stout_tests.cpp

Author: benh
Date: Sun Sep  9 22:03:16 2012
New Revision: 1382593

URL: http://svn.apache.org/viewvc?rev=1382593&view=rev
Log:
Added Duration comparison tests (https://reviews.apache.org/r/6837).

Modified:
    incubator/mesos/trunk/src/tests/stout_tests.cpp

Modified: incubator/mesos/trunk/src/tests/stout_tests.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/tests/stout_tests.cpp?rev=1382593&r1=1382592&r2=1382593&view=diff
==============================================================================
--- incubator/mesos/trunk/src/tests/stout_tests.cpp (original)
+++ incubator/mesos/trunk/src/tests/stout_tests.cpp Sun Sep  9 22:03:16 2012
@@ -5,6 +5,7 @@
 #include <vector>
 
 #include <stout/cache.hpp>
+#include <stout/duration.hpp>
 #include <stout/fatal.hpp>
 #include <stout/foreach.hpp>
 #include <stout/format.hpp>
@@ -27,6 +28,34 @@
 using namespace std;
 
 
+TEST(Stout, Duration)
+{
+  Try<Duration> _3hrs = Duration::parse("3hrs");
+  ASSERT_TRUE(_3hrs.isSome());
+
+  EXPECT_EQ(Hours(3.0), _3hrs.get());
+  EXPECT_EQ(Minutes(180.0), _3hrs.get());
+  EXPECT_EQ(Seconds(10800.0), _3hrs.get());
+  EXPECT_EQ(Milliseconds(10800000.0), _3hrs.get());
+
+  EXPECT_EQ(Milliseconds(1000.0), Seconds(1.0));
+
+  EXPECT_GT(Weeks(1.0), Days(6.0));
+
+  EXPECT_LT(Hours(23.0), Days(1.0));
+
+  EXPECT_LE(Hours(24.0), Days(1.0));
+  EXPECT_GE(Hours(24.0), Days(1.0));
+
+  EXPECT_NE(Minutes(59.0), Hours(1.0));
+
+  Try<Duration> _3_5hrs = Duration::parse("3.5hrs");
+  ASSERT_TRUE(_3_5hrs.isSome());
+
+  EXPECT_EQ(Hours(3.5), _3_5hrs.get());
+}
+
+
 TEST(StoutStringsTest, Format)
 {
   Try<std::string> result = strings::format("%s %s", "hello", "world");