core: use ndn-cxx scheduler::ScopedEventId

refs #4698

Change-Id: I5ab56855fb22824e129fd7e3ccfb53174cf34f82
diff --git a/tests/core/scheduler.t.cpp b/tests/core/scheduler.t.cpp
index a2ad752..88adb03 100644
--- a/tests/core/scheduler.t.cpp
+++ b/tests/core/scheduler.t.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
-/**
- * Copyright (c) 2014-2016,  Regents of the University of California,
+/*
+ * Copyright (c) 2014-2019,  Regents of the University of California,
  *                           Arizona Board of Regents,
  *                           Colorado State University,
  *                           University Pierre & Marie Curie, Sorbonne University,
@@ -30,7 +30,6 @@
 #include <boost/thread.hpp>
 
 namespace nfd {
-
 namespace scheduler {
 // defined in scheduler.cpp
 Scheduler&
@@ -39,58 +38,28 @@
 
 namespace tests {
 
-using scheduler::EventId;
-using scheduler::ScopedEventId;
-
 BOOST_FIXTURE_TEST_SUITE(TestScheduler, BaseFixture)
 
-class SchedulerFixture : protected BaseFixture
+BOOST_AUTO_TEST_CASE(ScheduleCancel)
 {
-public:
-  SchedulerFixture()
-    : count1(0)
-    , count2(0)
-    , count3(0)
-  {
-  }
+  int count1 = 0, count2 = 0, count3 = 0;
 
-  void
-  event1()
-  {
+  scheduler::schedule(500_ms, [&] {
     BOOST_CHECK_EQUAL(count3, 1);
     ++count1;
-  }
+  });
 
-  void
-  event2()
-  {
-    ++count2;
-  }
+  scheduler::EventId eid = scheduler::schedule(1_s, [&] { ++count2; });
+  scheduler::cancel(eid);
 
-  void
-  event3()
-  {
+  scheduler::schedule(250_ms, [&] {
     BOOST_CHECK_EQUAL(count1, 0);
     ++count3;
-  }
+  });
 
-public:
-  int count1;
-  int count2;
-  int count3;
-};
-
-BOOST_FIXTURE_TEST_CASE(Events, SchedulerFixture)
-{
-  scheduler::schedule(time::milliseconds(500), bind(&SchedulerFixture::event1, this));
-
-  EventId i = scheduler::schedule(time::seconds(1), bind(&SchedulerFixture::event2, this));
-  scheduler::cancel(i);
-
-  scheduler::schedule(time::milliseconds(250), bind(&SchedulerFixture::event3, this));
-
-  i = scheduler::schedule(time::milliseconds(50), bind(&SchedulerFixture::event2, this));
-  scheduler::cancel(i);
+  {
+    scheduler::ScopedEventId se = scheduler::schedule(50_ms, [&] { ++count2; });
+  } // se goes out of scope, canceling the event
 
   g_io.run();
 
@@ -99,87 +68,11 @@
   BOOST_CHECK_EQUAL(count3, 1);
 }
 
-BOOST_AUTO_TEST_CASE(CancelEmptyEvent)
-{
-  EventId i;
-  scheduler::cancel(i);
-
-  // Trivial check to avoid "test case did not check any assertions" message from Boost.Test
-  BOOST_CHECK(true);
-}
-
-class SelfCancelFixture : protected BaseFixture
-{
-public:
-  void
-  cancelSelf() const
-  {
-    scheduler::cancel(m_selfEventId);
-  }
-
-public:
-  EventId m_selfEventId;
-};
-
-BOOST_FIXTURE_TEST_CASE(SelfCancel, SelfCancelFixture)
-{
-  m_selfEventId = scheduler::schedule(time::milliseconds(100),
-                                      bind(&SelfCancelFixture::cancelSelf, this));
-
-  BOOST_REQUIRE_NO_THROW(g_io.run());
-}
-
-BOOST_FIXTURE_TEST_CASE(ScopedEventIdDestruct, UnitTestTimeFixture)
-{
-  int hit = 0;
-  {
-    ScopedEventId se = scheduler::schedule(time::milliseconds(10), [&] { ++hit; });
-  } // se goes out of scope
-  this->advanceClocks(time::milliseconds(1), 15);
-  BOOST_CHECK_EQUAL(hit, 0);
-}
-
-BOOST_FIXTURE_TEST_CASE(ScopedEventIdAssign, UnitTestTimeFixture)
-{
-  int hit1 = 0, hit2 = 0;
-  ScopedEventId se1 = scheduler::schedule(time::milliseconds(10), [&] { ++hit1; });
-  se1 = scheduler::schedule(time::milliseconds(10), [&] { ++hit2; });
-  this->advanceClocks(time::milliseconds(1), 15);
-  BOOST_CHECK_EQUAL(hit1, 0);
-  BOOST_CHECK_EQUAL(hit2, 1);
-}
-
-BOOST_FIXTURE_TEST_CASE(ScopedEventIdRelease, UnitTestTimeFixture)
-{
-  int hit = 0;
-  {
-    ScopedEventId se = scheduler::schedule(time::milliseconds(10), [&] { ++hit; });
-    se.release();
-  } // se goes out of scope
-  this->advanceClocks(time::milliseconds(1), 15);
-  BOOST_CHECK_EQUAL(hit, 1);
-}
-
-BOOST_FIXTURE_TEST_CASE(ScopedEventIdMove, UnitTestTimeFixture)
-{
-  int hit = 0;
-  unique_ptr<scheduler::ScopedEventId> se2;
-  {
-    ScopedEventId se = scheduler::schedule(time::milliseconds(10), [&] { ++hit; });
-    se2.reset(new ScopedEventId(std::move(se)));
-  } // se goes out of scope
-  this->advanceClocks(time::milliseconds(1), 15);
-  BOOST_CHECK_EQUAL(hit, 1);
-}
-
 BOOST_AUTO_TEST_CASE(ThreadLocalScheduler)
 {
   scheduler::Scheduler* s1 = &scheduler::getGlobalScheduler();
   scheduler::Scheduler* s2 = nullptr;
-  boost::thread t([&s2] {
-      s2 = &scheduler::getGlobalScheduler();
-    });
-
+  boost::thread t([&s2] { s2 = &scheduler::getGlobalScheduler(); });
   t.join();
 
   BOOST_CHECK(s1 != nullptr);