util: add literal operators for duration types

Change-Id: I007fa61c80e535c6e4b12e85a32eeeee62fecc3c
Refs: #4468
diff --git a/tests/unit-tests/util/dummy-client-face.t.cpp b/tests/unit-tests/util/dummy-client-face.t.cpp
index 8469d59..5308e28 100644
--- a/tests/unit-tests/util/dummy-client-face.t.cpp
+++ b/tests/unit-tests/util/dummy-client-face.t.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2013-2017 Regents of the University of California.
+ * Copyright (c) 2013-2018 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -37,11 +37,11 @@
   bool isOverrideInvoked = false;
   auto override = [&] (time::milliseconds timeout) {
     isOverrideInvoked = true;
-    BOOST_CHECK_EQUAL(timeout, time::milliseconds(200));
+    BOOST_CHECK_EQUAL(timeout, 200_ms);
   };
 
   DummyClientFace face(io, {false, false, override});
-  face.processEvents(time::milliseconds(200));
+  face.processEvents(200_ms);
   BOOST_CHECK(isOverrideInvoked);
 }
 
@@ -67,7 +67,7 @@
                             return;
                           }, nullptr, nullptr);
 
-  advanceClocks(time::milliseconds(25), 4);
+  advanceClocks(25_ms, 4);
 
   int nFace1Data = 0;
   int nFace2Nack = 0;
@@ -85,7 +85,7 @@
                           nFace2Nack++;
                         }, nullptr);
 
-  advanceClocks(time::milliseconds(10), 100);
+  advanceClocks(10_ms, 100);
 
   BOOST_CHECK_EQUAL(nFace1Data, 1);
   BOOST_CHECK_EQUAL(nFace2Nack, 1);
diff --git a/tests/unit-tests/util/notification-stream.t.cpp b/tests/unit-tests/util/notification-stream.t.cpp
index faedec8..3721091 100644
--- a/tests/unit-tests/util/notification-stream.t.cpp
+++ b/tests/unit-tests/util/notification-stream.t.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2017 Regents of the University of California,
+/*
+ * Copyright (c) 2014-2018 Regents of the University of California,
  *                         Arizona Board of Regents,
  *                         Colorado State University,
  *                         University Pierre & Marie Curie, Sorbonne University,
@@ -26,10 +26,10 @@
  */
 
 #include "util/notification-stream.hpp"
-#include "simple-notification.hpp"
 #include "util/dummy-client-face.hpp"
 
 #include "boost-test.hpp"
+#include "simple-notification.hpp"
 #include "../identity-management-time-fixture.hpp"
 
 namespace ndn {
@@ -48,11 +48,10 @@
   SimpleNotification event1("msg1");
   notificationStream.postNotification(event1);
 
-  advanceClocks(time::milliseconds(1));
+  advanceClocks(1_ms);
 
   BOOST_REQUIRE_EQUAL(face.sentData.size(), 1);
-  BOOST_CHECK_EQUAL(face.sentData[0].getName(),
-                    "/localhost/nfd/NotificationStreamTest/%FE%00");
+  BOOST_CHECK_EQUAL(face.sentData[0].getName(), "/localhost/nfd/NotificationStreamTest/%FE%00");
   SimpleNotification decoded1;
   BOOST_CHECK_NO_THROW(decoded1.wireDecode(face.sentData[0].getContent().blockFromValue()));
   BOOST_CHECK_EQUAL(decoded1.getMessage(), "msg1");
@@ -60,11 +59,10 @@
   SimpleNotification event2("msg2");
   notificationStream.postNotification(event2);
 
-  advanceClocks(time::milliseconds(1));
+  advanceClocks(1_ms);
 
   BOOST_REQUIRE_EQUAL(face.sentData.size(), 2);
-  BOOST_CHECK_EQUAL(face.sentData[1].getName(),
-                    "/localhost/nfd/NotificationStreamTest/%FE%01");
+  BOOST_CHECK_EQUAL(face.sentData[1].getName(), "/localhost/nfd/NotificationStreamTest/%FE%01");
   SimpleNotification decoded2;
   BOOST_CHECK_NO_THROW(decoded2.wireDecode(face.sentData[1].getContent().blockFromValue()));
   BOOST_CHECK_EQUAL(decoded2.getMessage(), "msg2");
diff --git a/tests/unit-tests/util/notification-subscriber.t.cpp b/tests/unit-tests/util/notification-subscriber.t.cpp
index aef46a3..3fe3fd6 100644
--- a/tests/unit-tests/util/notification-subscriber.t.cpp
+++ b/tests/unit-tests/util/notification-subscriber.t.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2017 Regents of the University of California,
+ * Copyright (c) 2014-2018 Regents of the University of California,
  *                         Arizona Board of Regents,
  *                         Colorado State University,
  *                         University Pierre & Marie Curie, Sorbonne University,
@@ -45,7 +45,7 @@
   NotificationSubscriberFixture()
     : streamPrefix("ndn:/NotificationSubscriberTest")
     , subscriberFace(io, m_keyChain)
-    , subscriber(subscriberFace, streamPrefix, time::seconds(1))
+    , subscriber(subscriberFace, streamPrefix, 1_s)
     , nextSendNotificationNo(0)
   {
   }
@@ -61,7 +61,7 @@
     dataName.appendSequenceNumber(nextSendNotificationNo);
     Data data(dataName);
     data.setContent(notification.wireEncode());
-    data.setFreshnessPeriod(time::seconds(1));
+    data.setFreshnessPeriod(1_s);
     m_keyChain.sign(data);
 
     lastDeliveredSeqNo = nextSendNotificationNo;
@@ -185,7 +185,7 @@
   this->connectHandlers();
   subscriber.start();
   BOOST_REQUIRE_EQUAL(subscriber.isRunning(), true);
-  advanceClocks(time::milliseconds(1));
+  advanceClocks(1_ms);
   BOOST_CHECK(this->hasInitialRequest());
 
   subscriberFace.sentInterests.clear();
@@ -198,19 +198,19 @@
 {
   this->connectHandlers();
   subscriber.start();
-  advanceClocks(time::milliseconds(1));
+  advanceClocks(1_ms);
 
   // respond to initial request
   subscriberFace.sentInterests.clear();
   this->deliverNotification("n1");
-  advanceClocks(time::milliseconds(1));
+  advanceClocks(1_ms);
   BOOST_CHECK_EQUAL(lastNotification.getMessage(), "n1");
   BOOST_CHECK_EQUAL(this->getRequestSeqNo(), lastDeliveredSeqNo + 1);
 
   // respond to continuation request
   subscriberFace.sentInterests.clear();
   this->deliverNotification("n2");
-  advanceClocks(time::milliseconds(1));
+  advanceClocks(1_ms);
   BOOST_CHECK_EQUAL(lastNotification.getMessage(), "n2");
   BOOST_CHECK_EQUAL(this->getRequestSeqNo(), lastDeliveredSeqNo + 1);
 }
@@ -219,17 +219,17 @@
 {
   this->connectHandlers();
   subscriber.start();
-  advanceClocks(time::milliseconds(1));
+  advanceClocks(1_ms);
 
   // send the first Nack to initial request
   BOOST_REQUIRE_EQUAL(subscriberFace.sentInterests.size(), 1);
   Interest interest = subscriberFace.sentInterests[0];
   subscriberFace.sentInterests.clear();
   this->deliverNack(interest, lp::NackReason::CONGESTION);
-  advanceClocks(time::milliseconds(1));
+  advanceClocks(1_ms);
   BOOST_CHECK_EQUAL(lastNack.getReason(), lp::NackReason::CONGESTION);
   BOOST_REQUIRE_EQUAL(this->hasInitialRequest(), false);
-  advanceClocks(time::milliseconds(300));
+  advanceClocks(300_ms);
   BOOST_REQUIRE_EQUAL(this->hasInitialRequest(), true);
 
   // send the second Nack to initial request
@@ -237,25 +237,25 @@
   interest = subscriberFace.sentInterests[0];
   subscriberFace.sentInterests.clear();
   this->deliverNack(interest, lp::NackReason::CONGESTION);
-  advanceClocks(time::milliseconds(301));
+  advanceClocks(301_ms);
   BOOST_REQUIRE_EQUAL(this->hasInitialRequest(), false);
-  advanceClocks(time::milliseconds(200));
+  advanceClocks(200_ms);
   BOOST_REQUIRE_EQUAL(this->hasInitialRequest(), true);
 
   // send a notification to initial request
   subscriberFace.sentInterests.clear();
   this->deliverNotification("n1");
-  advanceClocks(time::milliseconds(1));
+  advanceClocks(1_ms);
 
   // send a Nack to subsequent request
   BOOST_REQUIRE_EQUAL(subscriberFace.sentInterests.size(), 1);
   interest = subscriberFace.sentInterests[0];
   subscriberFace.sentInterests.clear();
   this->deliverNack(interest, lp::NackReason::CONGESTION);
-  advanceClocks(time::milliseconds(1));
+  advanceClocks(1_ms);
   BOOST_CHECK_EQUAL(lastNack.getReason(), lp::NackReason::CONGESTION);
   BOOST_REQUIRE_EQUAL(this->hasInitialRequest(), false);
-  advanceClocks(time::milliseconds(300));
+  advanceClocks(300_ms);
   BOOST_REQUIRE_EQUAL(this->hasInitialRequest(), true);
 }
 
@@ -263,7 +263,7 @@
 {
   this->connectHandlers();
   subscriber.start();
-  advanceClocks(time::milliseconds(1));
+  advanceClocks(1_ms);
 
   subscriberFace.sentInterests.clear();
   lastNotification.setMessage("");
@@ -274,7 +274,7 @@
 
   subscriberFace.sentInterests.clear();
   this->deliverNotification("n1");
-  advanceClocks(time::milliseconds(1));
+  advanceClocks(1_ms);
   BOOST_CHECK_EQUAL(lastNotification.getMessage(), "n1");
 }
 
@@ -282,7 +282,7 @@
 {
   this->connectHandlers();
   subscriber.start();
-  advanceClocks(time::milliseconds(1));
+  advanceClocks(1_ms);
 
   Name wrongName = streamPrefix;
   wrongName.append("%07%07");
@@ -291,7 +291,7 @@
   subscriberFace.receive(wrongData);
   subscriberFace.sentInterests.clear();
   lastNotification.setMessage("");
-  advanceClocks(time::milliseconds(1));
+  advanceClocks(1_ms);
   BOOST_CHECK(lastNotification.getMessage().empty());
   BOOST_CHECK_EQUAL(lastDecodeErrorData.getName(), wrongName);
   BOOST_CHECK(this->hasInitialRequest());
@@ -301,12 +301,12 @@
 {
   this->connectHandlers();
   subscriber.start();
-  advanceClocks(time::milliseconds(1));
+  advanceClocks(1_ms);
 
   subscriberFace.sentInterests.clear();
   lastNotification.setMessage("");
   this->deliverNotification("\x07n4");
-  advanceClocks(time::milliseconds(1));
+  advanceClocks(1_ms);
   BOOST_CHECK(lastNotification.getMessage().empty());
   BOOST_CHECK(this->hasInitialRequest());
 }
diff --git a/tests/unit-tests/util/scheduler.t.cpp b/tests/unit-tests/util/scheduler.t.cpp
index 8189f01..de54800 100644
--- a/tests/unit-tests/util/scheduler.t.cpp
+++ b/tests/unit-tests/util/scheduler.t.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2016 Regents of the University of California.
+/*
+ * Copyright (c) 2013-2018 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -55,27 +55,27 @@
   size_t count1 = 0;
   size_t count2 = 0;
 
-  scheduler.scheduleEvent(time::milliseconds(500), [&] {
+  scheduler.scheduleEvent(500_ms, [&] {
       ++count1;
       BOOST_CHECK_EQUAL(count2, 1);
     });
 
-  EventId i = scheduler.scheduleEvent(time::seconds(1), [&] {
+  EventId i = scheduler.scheduleEvent(1_s, [&] {
       BOOST_ERROR("This event should not have been fired");
     });
   scheduler.cancelEvent(i);
 
-  scheduler.scheduleEvent(time::milliseconds(250), [&] {
+  scheduler.scheduleEvent(250_ms, [&] {
       BOOST_CHECK_EQUAL(count1, 0);
       ++count2;
     });
 
-  i = scheduler.scheduleEvent(time::milliseconds(50), [&] {
+  i = scheduler.scheduleEvent(50_ms, [&] {
       BOOST_ERROR("This event should not have been fired");
     });
   scheduler.cancelEvent(i);
 
-  advanceClocks(time::milliseconds(25), time::milliseconds(1000));
+  advanceClocks(25_ms, 1000_ms);
   BOOST_CHECK_EQUAL(count1, 1);
   BOOST_CHECK_EQUAL(count2, 1);
 }
@@ -85,13 +85,13 @@
   class MyException : public std::exception
   {
   };
-  scheduler.scheduleEvent(time::milliseconds(10), [] { BOOST_THROW_EXCEPTION(MyException()); });
+  scheduler.scheduleEvent(10_ms, [] { BOOST_THROW_EXCEPTION(MyException()); });
 
   bool isCallbackInvoked = false;
-  scheduler.scheduleEvent(time::milliseconds(20), [&isCallbackInvoked] { isCallbackInvoked = true; });
+  scheduler.scheduleEvent(20_ms, [&isCallbackInvoked] { isCallbackInvoked = true; });
 
-  BOOST_CHECK_THROW(this->advanceClocks(time::milliseconds(6), 2), MyException);
-  this->advanceClocks(time::milliseconds(6), 2);
+  BOOST_CHECK_THROW(this->advanceClocks(6_ms, 2), MyException);
+  this->advanceClocks(6_ms, 2);
   BOOST_CHECK(isCallbackInvoked);
 }
 
@@ -107,11 +107,11 @@
 BOOST_AUTO_TEST_CASE(SelfCancel)
 {
   EventId selfEventId;
-  selfEventId = scheduler.scheduleEvent(time::milliseconds(100), [&] {
+  selfEventId = scheduler.scheduleEvent(100_ms, [&] {
       scheduler.cancelEvent(selfEventId);
     });
 
-  BOOST_REQUIRE_NO_THROW(advanceClocks(time::milliseconds(100), 10));
+  BOOST_REQUIRE_NO_THROW(advanceClocks(100_ms, 10));
 }
 
 class SelfRescheduleFixture : public SchedulerFixture
@@ -125,7 +125,7 @@
   void
   reschedule()
   {
-    EventId eventId = scheduler.scheduleEvent(time::milliseconds(100),
+    EventId eventId = scheduler.scheduleEvent(100_ms,
                                               bind(&SelfRescheduleFixture::reschedule, this));
     scheduler.cancelEvent(selfEventId);
     selfEventId = eventId;
@@ -142,7 +142,7 @@
     scheduler.cancelEvent(selfEventId);
 
     if (count < 5)  {
-      selfEventId = scheduler.scheduleEvent(time::milliseconds(100),
+      selfEventId = scheduler.scheduleEvent(100_ms,
                                             bind(&SelfRescheduleFixture::reschedule2, this));
       count++;
     }
@@ -153,12 +153,12 @@
   {
     scheduler.cancelEvent(selfEventId);
 
-    scheduler.scheduleEvent(time::milliseconds(100), [&] { ++count; });
-    scheduler.scheduleEvent(time::milliseconds(100), [&] { ++count; });
-    scheduler.scheduleEvent(time::milliseconds(100), [&] { ++count; });
-    scheduler.scheduleEvent(time::milliseconds(100), [&] { ++count; });
-    scheduler.scheduleEvent(time::milliseconds(100), [&] { ++count; });
-    scheduler.scheduleEvent(time::milliseconds(100), [&] { ++count; });
+    scheduler.scheduleEvent(100_ms, [&] { ++count; });
+    scheduler.scheduleEvent(100_ms, [&] { ++count; });
+    scheduler.scheduleEvent(100_ms, [&] { ++count; });
+    scheduler.scheduleEvent(100_ms, [&] { ++count; });
+    scheduler.scheduleEvent(100_ms, [&] { ++count; });
+    scheduler.scheduleEvent(100_ms, [&] { ++count; });
   }
 
 public:
@@ -168,30 +168,30 @@
 
 BOOST_FIXTURE_TEST_CASE(Reschedule, SelfRescheduleFixture)
 {
-  selfEventId = scheduler.scheduleEvent(time::seconds(0),
+  selfEventId = scheduler.scheduleEvent(0_s,
                                         bind(&SelfRescheduleFixture::reschedule, this));
 
-  BOOST_REQUIRE_NO_THROW(advanceClocks(time::milliseconds(50), time::milliseconds(1000)));
+  BOOST_REQUIRE_NO_THROW(advanceClocks(50_ms, 1000_ms));
 
   BOOST_CHECK_EQUAL(count, 5);
 }
 
 BOOST_FIXTURE_TEST_CASE(Reschedule2, SelfRescheduleFixture)
 {
-  selfEventId = scheduler.scheduleEvent(time::seconds(0),
+  selfEventId = scheduler.scheduleEvent(0_s,
                                         bind(&SelfRescheduleFixture::reschedule2, this));
 
-  BOOST_REQUIRE_NO_THROW(advanceClocks(time::milliseconds(50), time::milliseconds(1000)));
+  BOOST_REQUIRE_NO_THROW(advanceClocks(50_ms, 1000_ms));
 
   BOOST_CHECK_EQUAL(count, 5);
 }
 
 BOOST_FIXTURE_TEST_CASE(Reschedule3, SelfRescheduleFixture)
 {
-  selfEventId = scheduler.scheduleEvent(time::seconds(0),
+  selfEventId = scheduler.scheduleEvent(0_s,
                                         bind(&SelfRescheduleFixture::reschedule3, this));
 
-  BOOST_REQUIRE_NO_THROW(advanceClocks(time::milliseconds(50), time::milliseconds(1000)));
+  BOOST_REQUIRE_NO_THROW(advanceClocks(50_ms, 1000_ms));
 
   BOOST_CHECK_EQUAL(count, 6);
 }
@@ -209,7 +209,7 @@
   {
     ++count;
 
-    scheduler.scheduleEvent(time::seconds(1), [&] { event(); });
+    scheduler.scheduleEvent(1_s, [&] { event(); });
   }
 
 public:
@@ -218,15 +218,15 @@
 
 BOOST_FIXTURE_TEST_CASE(CancelAll, CancelAllFixture)
 {
-  scheduler.scheduleEvent(time::milliseconds(500), [&] { scheduler.cancelAllEvents(); });
+  scheduler.scheduleEvent(500_ms, [&] { scheduler.cancelAllEvents(); });
 
-  scheduler.scheduleEvent(time::seconds(1), [&] { event(); });
+  scheduler.scheduleEvent(1_s, [&] { event(); });
 
-  scheduler.scheduleEvent(time::seconds(3), [] {
+  scheduler.scheduleEvent(3_s, [] {
       BOOST_ERROR("This event should have been cancelled" );
     });
 
-  advanceClocks(time::milliseconds(100), 100);
+  advanceClocks(100_ms, 100);
 
   BOOST_CHECK_EQUAL(count, 0);
 }
@@ -235,7 +235,7 @@
 {
   Scheduler sched(io);
   ScopedEventId eid(sched);
-  eid = sched.scheduleEvent(time::milliseconds(10), []{});
+  eid = sched.scheduleEvent(10_ms, []{});
   sched.cancelAllEvents();
   eid.cancel(); // should not crash
 
@@ -266,7 +266,7 @@
   BOOST_CHECK_EQUAL(eid == nullptr, true);
   BOOST_CHECK_EQUAL(eid != nullptr, false);
 
-  eid = scheduler.scheduleEvent(time::milliseconds(10), []{});
+  eid = scheduler.scheduleEvent(10_ms, []{});
   BOOST_CHECK_EQUAL(eid == eid2, false);
   BOOST_CHECK_EQUAL(eid != eid2, true);
   BOOST_CHECK_EQUAL(eid == nullptr, false);
@@ -276,7 +276,7 @@
   BOOST_CHECK_EQUAL(eid == eid2, true);
   BOOST_CHECK_EQUAL(eid != eid2, false);
 
-  eid2 = scheduler.scheduleEvent(time::milliseconds(10), []{});
+  eid2 = scheduler.scheduleEvent(10_ms, []{});
   BOOST_CHECK_EQUAL(eid == eid2, false);
   BOOST_CHECK_EQUAL(eid != eid2, true);
 }
@@ -287,7 +287,7 @@
   BOOST_CHECK_EQUAL(static_cast<bool>(eid), false);
   BOOST_CHECK_EQUAL(!eid, true);
 
-  eid = scheduler.scheduleEvent(time::milliseconds(10), []{});
+  eid = scheduler.scheduleEvent(10_ms, []{});
   BOOST_CHECK_EQUAL(static_cast<bool>(eid), true);
   BOOST_CHECK_EQUAL(!eid, false);
 
@@ -302,10 +302,10 @@
 BOOST_AUTO_TEST_CASE(DuringCallback)
 {
   EventId eid;
-  EventId eid2 = scheduler.scheduleEvent(time::milliseconds(20), []{});
+  EventId eid2 = scheduler.scheduleEvent(20_ms, []{});
 
   bool isCallbackInvoked = false;
-  eid = scheduler.scheduleEvent(time::milliseconds(10), [this, &eid, &eid2, &isCallbackInvoked] {
+  eid = scheduler.scheduleEvent(10_ms, [this, &eid, &eid2, &isCallbackInvoked] {
     isCallbackInvoked = true;
 
     // eid is "expired" during callback execution
@@ -320,20 +320,20 @@
     BOOST_CHECK_EQUAL(eid == eid2, true);
     BOOST_CHECK_EQUAL(eid != eid2, false);
   });
-  this->advanceClocks(time::milliseconds(6), 2);
+  this->advanceClocks(6_ms, 2);
   BOOST_CHECK(isCallbackInvoked);
 }
 
 BOOST_AUTO_TEST_CASE(Reset)
 {
   bool isCallbackInvoked = false;
-  EventId eid = scheduler.scheduleEvent(time::milliseconds(10),
+  EventId eid = scheduler.scheduleEvent(10_ms,
                                         [&isCallbackInvoked]{ isCallbackInvoked = true; });
   eid.reset();
   BOOST_CHECK_EQUAL(!eid, true);
   BOOST_CHECK_EQUAL(eid == nullptr, true);
 
-  this->advanceClocks(time::milliseconds(6), 2);
+  this->advanceClocks(6_ms, 2);
   BOOST_CHECK(isCallbackInvoked);
 }
 
@@ -344,7 +344,7 @@
   EventId eid;
   BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(eid), nullString);
 
-  eid = scheduler.scheduleEvent(time::milliseconds(10), []{});
+  eid = scheduler.scheduleEvent(10_ms, []{});
   BOOST_TEST_MESSAGE("eid=" << eid);
   BOOST_CHECK_NE(boost::lexical_cast<std::string>(eid), nullString);
 }
@@ -360,9 +360,9 @@
   int hit = 0;
   {
     ScopedEventId se(scheduler);
-    se = scheduler.scheduleEvent(time::milliseconds(10), [&] { ++hit; });
+    se = scheduler.scheduleEvent(10_ms, [&] { ++hit; });
   } // se goes out of scope
-  this->advanceClocks(time::milliseconds(1), 15);
+  this->advanceClocks(1_ms, 15);
   BOOST_CHECK_EQUAL(hit, 0);
 }
 
@@ -370,9 +370,9 @@
 {
   int hit1 = 0, hit2 = 0;
   ScopedEventId se1(scheduler);
-  se1 = scheduler.scheduleEvent(time::milliseconds(10), [&] { ++hit1; });
-  se1 = scheduler.scheduleEvent(time::milliseconds(10), [&] { ++hit2; });
-  this->advanceClocks(time::milliseconds(1), 15);
+  se1 = scheduler.scheduleEvent(10_ms, [&] { ++hit1; });
+  se1 = scheduler.scheduleEvent(10_ms, [&] { ++hit2; });
+  this->advanceClocks(1_ms, 15);
   BOOST_CHECK_EQUAL(hit1, 0);
   BOOST_CHECK_EQUAL(hit2, 1);
 }
@@ -382,10 +382,10 @@
   int hit = 0;
   {
     ScopedEventId se(scheduler);
-    se = scheduler.scheduleEvent(time::milliseconds(10), [&] { ++hit; });
+    se = scheduler.scheduleEvent(10_ms, [&] { ++hit; });
     se.release();
   } // se goes out of scope
-  this->advanceClocks(time::milliseconds(1), 15);
+  this->advanceClocks(1_ms, 15);
   BOOST_CHECK_EQUAL(hit, 1);
 }
 
@@ -395,10 +395,10 @@
   unique_ptr<scheduler::ScopedEventId> se2;
   {
     ScopedEventId se(scheduler);
-    se = scheduler.scheduleEvent(time::milliseconds(10), [&] { ++hit; });
+    se = scheduler.scheduleEvent(10_ms, [&] { ++hit; });
     se2.reset(new ScopedEventId(std::move(se)));
   } // se goes out of scope
-  this->advanceClocks(time::milliseconds(1), 15);
+  this->advanceClocks(1_ms, 15);
   BOOST_CHECK_EQUAL(hit, 1);
 }
 
diff --git a/tests/unit-tests/util/segment-fetcher.t.cpp b/tests/unit-tests/util/segment-fetcher.t.cpp
index 0b512e8..edcb9ca 100644
--- a/tests/unit-tests/util/segment-fetcher.t.cpp
+++ b/tests/unit-tests/util/segment-fetcher.t.cpp
@@ -82,7 +82,7 @@
     const Interest& lastInterest = face.sentInterests.back();
     lp::Nack nack = makeNack(lastInterest, nackReason);
     face.receive(nack);
-    advanceClocks(time::milliseconds(10));
+    advanceClocks(10_ms);
   }
 
 public:
@@ -98,12 +98,12 @@
 BOOST_FIXTURE_TEST_CASE(Timeout, Fixture)
 {
   DummyValidator acceptValidator;
-  SegmentFetcher::fetch(face, Interest("/hello/world", time::milliseconds(100)),
+  SegmentFetcher::fetch(face, Interest("/hello/world", 100_ms),
                         acceptValidator,
                         bind(&Fixture::onComplete, this, _1),
                         bind(&Fixture::onError, this, _1));
 
-  advanceClocks(time::milliseconds(1));
+  advanceClocks(1_ms);
   BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 1);
 
   const Interest& interest = face.sentInterests[0];
@@ -111,12 +111,12 @@
   BOOST_CHECK_EQUAL(interest.getMustBeFresh(), true);
   BOOST_CHECK_EQUAL(interest.getChildSelector(), 1);
 
-  advanceClocks(time::milliseconds(98));
+  advanceClocks(98_ms);
   BOOST_CHECK_EQUAL(nErrors, 0);
   BOOST_CHECK_EQUAL(nData, 0);
   BOOST_CHECK_EQUAL(face.sentData.size(), 0);
 
-  advanceClocks(time::milliseconds(1), 2);
+  advanceClocks(1_ms, 2);
   BOOST_CHECK_EQUAL(nErrors, 1);
   BOOST_CHECK_EQUAL(lastError, static_cast<uint32_t>(SegmentFetcher::INTEREST_TIMEOUT));
   BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 1);
@@ -127,15 +127,15 @@
 BOOST_FIXTURE_TEST_CASE(Basic, Fixture)
 {
   DummyValidator acceptValidator;
-  SegmentFetcher::fetch(face, Interest("/hello/world", time::seconds(1000)),
+  SegmentFetcher::fetch(face, Interest("/hello/world", 1000_s),
                         acceptValidator,
                         bind(&Fixture::onComplete, this, _1),
                         bind(&Fixture::onError, this, _1));
 
-  advanceClocks(time::milliseconds(10));
+  advanceClocks(10_ms);
 
   face.receive(*makeDataSegment("/hello/world/version0", 0, true));
-  advanceClocks(time::milliseconds(10));
+  advanceClocks(10_ms);
 
   BOOST_CHECK_EQUAL(nErrors, 0);
   BOOST_CHECK_EQUAL(nData, 1);
@@ -159,19 +159,19 @@
 BOOST_FIXTURE_TEST_CASE(NoSegmentInData, Fixture)
 {
   DummyValidator acceptValidator;
-  SegmentFetcher::fetch(face, Interest("/hello/world", time::seconds(1000)),
+  SegmentFetcher::fetch(face, Interest("/hello/world", 1000_s),
                         acceptValidator,
                         bind(&Fixture::onComplete, this, _1),
                         bind(&Fixture::onError, this, _1));
 
-  advanceClocks(time::milliseconds(10));
+  advanceClocks(10_ms);
 
   const uint8_t buffer[] = "Hello, world!";
   auto data = makeData("/hello/world/version0/no-segment");
   data->setContent(buffer, sizeof(buffer));
 
   face.receive(*data);
-  advanceClocks(time::milliseconds(10));
+  advanceClocks(10_ms);
 
   BOOST_CHECK_EQUAL(nErrors, 1);
   BOOST_CHECK_EQUAL(lastError, static_cast<uint32_t>(SegmentFetcher::DATA_HAS_NO_SEGMENT));
@@ -181,14 +181,14 @@
 BOOST_FIXTURE_TEST_CASE(SegmentValidationFailure, Fixture)
 {
   DummyValidator rejectValidator(false);
-  SegmentFetcher::fetch(face, Interest("/hello/world", time::seconds(1000)),
+  SegmentFetcher::fetch(face, Interest("/hello/world", 1000_s),
                         rejectValidator,
                         bind(&Fixture::onComplete, this, _1),
                         bind(&Fixture::onError, this, _1));
 
-  advanceClocks(time::milliseconds(10));
+  advanceClocks(10_ms);
   face.receive(*makeDataSegment("/hello/world/version0", 0, true));
-  advanceClocks(time::milliseconds(10));
+  advanceClocks(10_ms);
 
   BOOST_CHECK_EQUAL(nErrors, 1);
   BOOST_CHECK_EQUAL(lastError, static_cast<uint32_t>(SegmentFetcher::SEGMENT_VALIDATION_FAIL));
@@ -198,21 +198,21 @@
 BOOST_FIXTURE_TEST_CASE(Triple, Fixture)
 {
   DummyValidator acceptValidator;
-  SegmentFetcher::fetch(face, Interest("/hello/world", time::seconds(1000)),
+  SegmentFetcher::fetch(face, Interest("/hello/world", 1000_s),
                         acceptValidator,
                         bind(&Fixture::onComplete, this, _1),
                         bind(&Fixture::onError, this, _1));
 
-  advanceClocks(time::milliseconds(10));
+  advanceClocks(10_ms);
   face.receive(*makeDataSegment("/hello/world/version0", 0, false));
 
-  advanceClocks(time::milliseconds(10));
+  advanceClocks(10_ms);
   face.receive(*makeDataSegment("/hello/world/version0", 1, false));
 
-  advanceClocks(time::milliseconds(10));
+  advanceClocks(10_ms);
   face.receive(*makeDataSegment("/hello/world/version0", 2, true));
 
-  advanceClocks(time::milliseconds(10));
+  advanceClocks(10_ms);
 
   BOOST_CHECK_EQUAL(nErrors, 0);
   BOOST_CHECK_EQUAL(nData, 1);
@@ -247,24 +247,24 @@
 BOOST_FIXTURE_TEST_CASE(TripleWithInitialSegmentFetching, Fixture)
 {
   DummyValidator acceptValidator;
-  SegmentFetcher::fetch(face, Interest("/hello/world", time::seconds(1000)),
+  SegmentFetcher::fetch(face, Interest("/hello/world", 1000_s),
                         acceptValidator,
                         bind(&Fixture::onComplete, this, _1),
                         bind(&Fixture::onError, this, _1));
 
-  advanceClocks(time::milliseconds(10));
+  advanceClocks(10_ms);
   face.receive(*makeDataSegment("/hello/world/version0", 1, false));
 
-  advanceClocks(time::milliseconds(10));
+  advanceClocks(10_ms);
   face.receive(*makeDataSegment("/hello/world/version0", 0, false));
 
-  advanceClocks(time::milliseconds(10));
+  advanceClocks(10_ms);
   face.receive(*makeDataSegment("/hello/world/version0", 1, false));
 
-  advanceClocks(time::milliseconds(10));
+  advanceClocks(10_ms);
   face.receive(*makeDataSegment("/hello/world/version0", 2, true));
 
-  advanceClocks(time::milliseconds(10));
+  advanceClocks(10_ms);
 
   BOOST_CHECK_EQUAL(nErrors, 0);
   BOOST_CHECK_EQUAL(nData, 1);
@@ -306,21 +306,21 @@
 BOOST_FIXTURE_TEST_CASE(MultipleSegmentFetching, Fixture)
 {
   DummyValidator acceptValidator;
-  SegmentFetcher::fetch(face, Interest("/hello/world", time::seconds(1000)),
+  SegmentFetcher::fetch(face, Interest("/hello/world", 1000_s),
                         acceptValidator,
                         bind(&Fixture::onComplete, this, _1),
                         bind(&Fixture::onError, this, _1));
 
-  advanceClocks(time::milliseconds(10));
+  advanceClocks(10_ms);
 
   for (uint64_t i = 0; i < 400; i++) {
-    advanceClocks(time::milliseconds(10));
+    advanceClocks(10_ms);
     face.receive(*makeDataSegment("/hello/world/version0", i, false));
   }
-  advanceClocks(time::milliseconds(10));
+  advanceClocks(10_ms);
   face.receive(*makeDataSegment("/hello/world/version0", 400, true));
 
-  advanceClocks(time::milliseconds(10));
+  advanceClocks(10_ms);
 
   BOOST_CHECK_EQUAL(nErrors, 0);
   BOOST_CHECK_EQUAL(nData, 1);
@@ -328,11 +328,11 @@
 
 BOOST_FIXTURE_TEST_CASE(DuplicateNack, Fixture)
 {
-  SegmentFetcher::fetch(face, Interest("/hello/world", time::seconds(1000)),
+  SegmentFetcher::fetch(face, Interest("/hello/world", 1000_s),
                         make_shared<DummyValidator>(true),
                         bind(&Fixture::onComplete, this, _1),
                         bind(&Fixture::onError, this, _1));
-  advanceClocks(time::milliseconds(10));
+  advanceClocks(10_ms);
 
   // receive nack for the original interest
   nackLastInterest(lp::NackReason::DUPLICATE);
@@ -348,11 +348,11 @@
 
 BOOST_FIXTURE_TEST_CASE(CongestionNack, Fixture)
 {
-  SegmentFetcher::fetch(face, Interest("/hello/world", time::seconds(1000)),
+  SegmentFetcher::fetch(face, Interest("/hello/world", 1000_s),
                         make_shared<DummyValidator>(true),
                         bind(&Fixture::onComplete, this, _1),
                         bind(&Fixture::onError, this, _1));
-  advanceClocks(time::milliseconds(10));
+  advanceClocks(10_ms);
 
   // receive nack for the original interest
   nackLastInterest(lp::NackReason::CONGESTION);
@@ -377,19 +377,19 @@
                         bind(&Fixture::onComplete, this, _1),
                         bind(&Fixture::onError, this, _1));
 
-  advanceClocks(time::milliseconds(1000));
+  advanceClocks(1000_ms);
 
   for (uint64_t segmentNo = 0; segmentNo <= 3; segmentNo++) {
     if (segmentNo == 1) {
       while (nNacks--) {
         nackLastInterest(lp::NackReason::CONGESTION);
-        advanceClocks(time::milliseconds(10));
+        advanceClocks(10_ms);
       }
     }
 
     auto data = makeDataSegment(interestName, segmentNo, segmentNo == 3);
     face.receive(*data);
-    advanceClocks(time::milliseconds(10));
+    advanceClocks(10_ms);
   }
 
   // Total number of sent interests should be 6: one interest for segment zero and segment one each,
@@ -411,7 +411,7 @@
                         make_shared<DummyValidator>(true),
                         bind(&Fixture::onComplete, this, _1),
                         bind(&Fixture::onError, this, _1));
-  advanceClocks(time::milliseconds(10));
+  advanceClocks(10_ms);
   nackLastInterest(lp::NackReason::DUPLICATE);
   face.receive(*makeDataSegment("/hello/world", 0, true));
 
@@ -430,7 +430,7 @@
       return flipResult;
     });
   shared_ptr<SegmentFetcher> fetcher =
-    SegmentFetcher::fetch(face, Interest("/hello/world", time::seconds(1000)),
+    SegmentFetcher::fetch(face, Interest("/hello/world", 1000_s),
                           validator,
                           bind(&Fixture::onComplete, this, _1),
                           bind(&Fixture::onError, this, _1));
@@ -448,15 +448,15 @@
       ++nValidatedSegments;
     });
 
-  advanceClocks(time::milliseconds(10), 10);
+  advanceClocks(10_ms, 10);
 
   face.receive(*data1);
 
-  advanceClocks(time::milliseconds(10), 10);
+  advanceClocks(10_ms, 10);
 
   face.receive(*data2);
 
-  advanceClocks(time::milliseconds(10), 10);
+  advanceClocks(10_ms, 10);
 
   BOOST_CHECK_EQUAL(nRecvSegments, 2);
   BOOST_CHECK_EQUAL(nValidatedSegments, 1);
diff --git a/tests/unit-tests/util/time-unit-test-clock.t.cpp b/tests/unit-tests/util/time-unit-test-clock.t.cpp
index 20330fd..dd8346a 100644
--- a/tests/unit-tests/util/time-unit-test-clock.t.cpp
+++ b/tests/unit-tests/util/time-unit-test-clock.t.cpp
@@ -43,11 +43,11 @@
   BOOST_CHECK_EQUAL(time::system_clock::now().time_since_epoch(),
                     time::UnitTestClockTraits<time::system_clock>::getDefaultStartTime());
 
-  steadyClock->advance(time::days(1));
+  steadyClock->advance(1_day);
   BOOST_CHECK_EQUAL(time::system_clock::now().time_since_epoch(),
                     time::UnitTestClockTraits<time::system_clock>::getDefaultStartTime());
 
-  systemClock->advance(time::days(1));
+  systemClock->advance(1_day);
   BOOST_CHECK_GT(time::system_clock::now().time_since_epoch(),
                  time::UnitTestClockTraits<time::system_clock>::getDefaultStartTime());
 
@@ -77,16 +77,16 @@
   BOOST_CHECK_EQUAL(time::fromIsoString("20140129T034247.032000"), referenceTime);
   BOOST_CHECK_EQUAL(time::fromIsoString("20140129T034247.032000Z"), referenceTime);
   BOOST_CHECK_EQUAL(time::fromString("2014-01-29 03:42:47"),
-                    time::fromUnixTimestamp(time::seconds(1390966967)));
+                    time::fromUnixTimestamp(1390966967_s));
 
   // Unfortunately, not all systems has lv_LV locale installed :(
   // BOOST_CHECK_EQUAL(time::fromString("2014. gada 29. Janvāris", "%Y. gada %d. %B",
   //                                    std::locale("lv_LV.UTF-8")),
-  //                   time::fromUnixTimestamp(time::seconds(1390953600)));
+  //                   time::fromUnixTimestamp(1390953600_s));
 
   BOOST_CHECK_EQUAL(time::fromString("2014 -- 29 -- January", "%Y -- %d -- %B",
                                      std::locale("C")),
-                    time::fromUnixTimestamp(time::seconds(1390953600)));
+                    time::fromUnixTimestamp(1390953600_s));
 }
 
 BOOST_AUTO_TEST_CASE(SteadyClock)
@@ -98,18 +98,18 @@
   BOOST_CHECK_EQUAL(time::steady_clock::now().time_since_epoch(),
                     time::steady_clock::duration::zero());
 
-  systemClock->advance(time::days(36500));
+  systemClock->advance(36500_days);
   BOOST_CHECK_EQUAL(time::steady_clock::now().time_since_epoch(),
                     time::steady_clock::duration::zero());
 
-  steadyClock->advance(time::nanoseconds(100));
-  BOOST_CHECK_EQUAL(time::steady_clock::now().time_since_epoch(), time::nanoseconds(100));
+  steadyClock->advance(100_ns);
+  BOOST_CHECK_EQUAL(time::steady_clock::now().time_since_epoch(), 100_ns);
 
-  steadyClock->advance(time::microseconds(100));
-  BOOST_CHECK_EQUAL(time::steady_clock::now().time_since_epoch(), time::nanoseconds(100100));
+  steadyClock->advance(100_us);
+  BOOST_CHECK_EQUAL(time::steady_clock::now().time_since_epoch(), 100100_ns);
 
-  steadyClock->setNow(time::milliseconds(1));
-  BOOST_CHECK_EQUAL(time::steady_clock::now().time_since_epoch(), time::nanoseconds(1000000));
+  steadyClock->setNow(1_ms);
+  BOOST_CHECK_EQUAL(time::steady_clock::now().time_since_epoch(), 1000000_ns);
 
   BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(time::steady_clock::now()),
                     "1000000 nanoseconds since unit test beginning");
@@ -120,12 +120,12 @@
   ndn::Scheduler scheduler(io);
 
   bool hasFired = false;
-  scheduler.scheduleEvent(time::seconds(100), [&] { hasFired = true; });
+  scheduler.scheduleEvent(100_s, [&] { hasFired = true; });
 
   io.poll();
   BOOST_CHECK_EQUAL(hasFired, false);
 
-  steadyClock->advance(time::seconds(100));
+  steadyClock->advance(100_s);
 
   io.poll();
   BOOST_CHECK_EQUAL(hasFired, true);
diff --git a/tests/unit-tests/util/time.t.cpp b/tests/unit-tests/util/time.t.cpp
index 3d7160d..58fdfae 100644
--- a/tests/unit-tests/util/time.t.cpp
+++ b/tests/unit-tests/util/time.t.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2013-2017 Regents of the University of California.
+/*
+ * Copyright (c) 2013-2018 Regents of the University of California.
  *
  * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
  *
@@ -23,6 +23,8 @@
 
 #include "boost-test.hpp"
 
+#include <thread>
+
 namespace ndn {
 namespace time {
 namespace tests {
@@ -42,12 +44,10 @@
   BOOST_CHECK_EQUAL(toString(referenceTime), "2014-01-29 03:42:47");
 
   // Unfortunately, not all systems has lv_LV locale installed :(
-  // BOOST_CHECK_EQUAL(toString(referenceTime, "%Y. gada %d. %B",
-  //                                  std::locale("lv_LV.UTF-8")),
+  // BOOST_CHECK_EQUAL(toString(referenceTime, "%Y. gada %d. %B", std::locale("lv_LV.UTF-8")),
   //                   "2014. gada 29. Janvāris");
 
-  BOOST_CHECK_EQUAL(toString(referenceTime, "%Y -- %d -- %B",
-                                   std::locale("C")),
+  BOOST_CHECK_EQUAL(toString(referenceTime, "%Y -- %d -- %B", std::locale("C")),
                     "2014 -- 29 -- January");
 
   BOOST_CHECK_EQUAL(fromIsoString("20140129T034247.032000"), referenceTime);
@@ -56,21 +56,18 @@
                     fromUnixTimestamp(seconds(1390966967)));
 
   // Unfortunately, not all systems has lv_LV locale installed :(
-  // BOOST_CHECK_EQUAL(fromString("2014. gada 29. Janvāris", "%Y. gada %d. %B",
-  //                                    std::locale("lv_LV.UTF-8")),
+  // BOOST_CHECK_EQUAL(fromString("2014. gada 29. Janvāris", "%Y. gada %d. %B", std::locale("lv_LV.UTF-8")),
   //                   fromUnixTimestamp(seconds(1390953600)));
 
-  BOOST_CHECK_EQUAL(fromString("2014 -- 29 -- January", "%Y -- %d -- %B",
-                                     std::locale("C")),
+  BOOST_CHECK_EQUAL(fromString("2014 -- 29 -- January", "%Y -- %d -- %B", std::locale("C")),
                     fromUnixTimestamp(seconds(1390953600)));
 }
 
 BOOST_AUTO_TEST_CASE(SteadyClock)
 {
   steady_clock::TimePoint oldValue = steady_clock::now();
-  usleep(100);
+  std::this_thread::sleep_for(std::chrono::milliseconds(1));
   steady_clock::TimePoint newValue = steady_clock::now();
-
   BOOST_CHECK_GT(newValue, oldValue);
 }
 
@@ -83,13 +80,41 @@
 
 BOOST_AUTO_TEST_CASE(LargeDates)
 {
-  system_clock::TimePoint value = fromUnixTimestamp(milliseconds(1390966967032LL));
+  auto value = fromUnixTimestamp(milliseconds(1390966967032LL));
   BOOST_CHECK_EQUAL(toIsoString(value), "20140129T034247.032000");
 
   value += days(365 * 100 + 25 - 1); // 36524 days
   BOOST_CHECK_EQUAL(toIsoString(value), "21140129T034247.032000");
 }
 
+BOOST_AUTO_TEST_CASE(Literals)
+{
+  BOOST_CHECK_EQUAL(42_s, seconds(42));
+
+  BOOST_CHECK_EQUAL(1_day, 24_h);
+  BOOST_CHECK_EQUAL(2_days, 48_h);
+  BOOST_CHECK_EQUAL(0.5_day, 12_h);
+  BOOST_CHECK_EQUAL(.5_days, 12_h);
+
+  BOOST_CHECK_EQUAL(1_h, 60_min);
+  BOOST_CHECK_EQUAL(0.5_h, 30_min);
+
+  BOOST_CHECK_EQUAL(1_min, 60_s);
+  BOOST_CHECK_EQUAL(0.5_min, 30_s);
+
+  BOOST_CHECK_EQUAL(1_s, 1000_ms);
+  BOOST_CHECK_EQUAL(0.5_s, 500_ms);
+
+  BOOST_CHECK_EQUAL(1_ms, 1000_us);
+  BOOST_CHECK_EQUAL(0.5_ms, 500_us);
+
+  BOOST_CHECK_EQUAL(1_us, 1000_ns);
+  BOOST_CHECK_EQUAL(0.5_us, 500_ns);
+
+  BOOST_CHECK_EQUAL(1_ns, nanoseconds(1));
+  BOOST_CHECK_EQUAL(5.5_ns, 0.0055_us);
+}
+
 BOOST_AUTO_TEST_SUITE_END() // TestTime
 BOOST_AUTO_TEST_SUITE_END() // Util