about summary refs log tree commit diff homepage
path: root/unittests
diff options
context:
space:
mode:
authorFrank Busse <bb0xfb@gmail.com>2019-03-11 11:09:34 +0000
committerMartinNowack <martin.nowack@gmail.com>2019-03-12 00:20:57 +0000
commit59eb5a817471ad0887706637c4e43ff474e7fb63 (patch)
treeb6f00f7c34d231f8feca0c320970289b8cd136b3 /unittests
parent0e92811fe7ba7b98425391ef8f8995174afc4f74 (diff)
downloadklee-59eb5a817471ad0887706637c4e43ff474e7fb63.tar.gz
time: add double type for span multiplications
Diffstat (limited to 'unittests')
-rw-r--r--unittests/Time/TimeTest.cpp28
1 files changed, 24 insertions, 4 deletions
diff --git a/unittests/Time/TimeTest.cpp b/unittests/Time/TimeTest.cpp
index 9caa14fd..a05c41b4 100644
--- a/unittests/Time/TimeTest.cpp
+++ b/unittests/Time/TimeTest.cpp
@@ -103,13 +103,13 @@ TEST(TimeTest, TimeArithmeticAndComparisons) {
   ASSERT_LT(sec, sec2);
 
   auto op0 = time::seconds(1);
-  auto op1 = op0 / 1000;
+  auto op1 = op0 / 1000U;
   ASSERT_EQ(op1, ms);
   op0 = time::nanoseconds(3);
-  op1 = op0 * 1000;
-  ASSERT_EQ(op1, 3*us);
+  op1 = op0 * 1000U;
+  ASSERT_EQ(op1, 3U*us);
 
-  op0 = (time::seconds(10) + time::minutes(1) - time::milliseconds(10000)) * 60;
+  op0 = (time::seconds(10) + time::minutes(1) - time::milliseconds(10000)) * 60U;
   ASSERT_EQ(op0, h);
 
   auto p1 = time::getWallTime();
@@ -163,3 +163,23 @@ TEST(TimeTest, TimeConversions) {
   os << time::Span("2.5");
   ASSERT_EQ(os.str(), "2.5s");
 }
+
+TEST(TimeTest, ImplicitArithmeticConversions) {
+  auto t1 = time::Span("1000s");
+  t1 *= 2U;
+  auto d = t1.toSeconds();
+  ASSERT_EQ(d, 2000.0);
+
+  auto t2 = t1 * 1.5;
+  d = t2.toSeconds();
+  ASSERT_EQ(d, 3000.0);
+
+  t2 = 2.5 * t1;
+  d = t2.toSeconds();
+  ASSERT_EQ(d, 5000.0);
+
+  t1 = time::Span("1000s");
+  t1 *= 2.2;
+  d = t1.toSeconds();
+  ASSERT_EQ(d, 2200.0);
+}
\ No newline at end of file