unit test Time::operator<< timefunc-fixes
authorPhilipp Gesang <philipp.gesang@intra2net.com>
Fri, 26 Apr 2019 15:00:12 +0000 (17:00 +0200)
committerPhilipp Gesang <philipp.gesang@intra2net.com>
Fri, 26 Apr 2019 15:00:12 +0000 (17:00 +0200)
test/test_timefunc.cpp

index 74174c7..5705c22 100644 (file)
@@ -44,6 +44,7 @@ on this file might be covered by the GNU General Public License.
 #include <unistd.h>
 #include <set>
 #include <iostream>
+#include <sstream>
 
 using namespace std;
 using namespace I2n;
@@ -1524,6 +1525,24 @@ BOOST_AUTO_TEST_SUITE(Clock)
         BOOST_CHECK_EQUAL(I2n::clock::median (ts), I2n::clock::Time (0xf00d));
     }
 
+    BOOST_AUTO_TEST_CASE(operator_shift_left)
+    {
+        std::ostringstream os1;
+        std::ostringstream os2;
+        std::ostringstream os3;
+        std::ostringstream os4;
+
+        os1 << I2n::clock::Time ( 42,  42);
+        os2 << I2n::clock::Time (-42,  42);
+        os3 << I2n::clock::Time ( 42, -42);
+        os4 << I2n::clock::Time (-42, -42);
+
+        BOOST_CHECK_EQUAL(os1.str (),  "42s, 42ns");
+        BOOST_CHECK_EQUAL(os2.str (), "-42s, 42ns");
+        BOOST_CHECK_EQUAL(os3.str (),  "41s, 999999958ns");
+        BOOST_CHECK_EQUAL(os4.str (), "-43s, 999999958ns");
+    }
+
 BOOST_AUTO_TEST_SUITE_END() /* [Clock] */
 
 BOOST_AUTO_TEST_SUITE_END()