folly: build with -Wunused-parameter
[folly.git] / folly / futures / test / InterruptTest.cpp
index 7d34106fe8954e3246b97291fca7bf6bd8dd4605..3ba584c1bbd1ef9397b5cbc88fb8a786a39ffe2e 100644 (file)
@@ -42,7 +42,7 @@ TEST(Interrupt, cancel) {
 TEST(Interrupt, handleThenInterrupt) {
   Promise<int> p;
   bool flag = false;
-  p.setInterruptHandler([&](const exception_wrapper& e) { flag = true; });
+  p.setInterruptHandler([&](const exception_wrapper& /* e */) { flag = true; });
   p.getFuture().cancel();
   EXPECT_TRUE(flag);
 }
@@ -51,14 +51,14 @@ TEST(Interrupt, interruptThenHandle) {
   Promise<int> p;
   bool flag = false;
   p.getFuture().cancel();
-  p.setInterruptHandler([&](const exception_wrapper& e) { flag = true; });
+  p.setInterruptHandler([&](const exception_wrapper& /* e */) { flag = true; });
   EXPECT_TRUE(flag);
 }
 
 TEST(Interrupt, interruptAfterFulfilNoop) {
   Promise<Unit> p;
   bool flag = false;
-  p.setInterruptHandler([&](const exception_wrapper& e) { flag = true; });
+  p.setInterruptHandler([&](const exception_wrapper& /* e */) { flag = true; });
   p.setValue();
   p.getFuture().cancel();
   EXPECT_FALSE(flag);
@@ -67,7 +67,7 @@ TEST(Interrupt, interruptAfterFulfilNoop) {
 TEST(Interrupt, secondInterruptNoop) {
   Promise<Unit> p;
   int count = 0;
-  p.setInterruptHandler([&](const exception_wrapper& e) { count++; });
+  p.setInterruptHandler([&](const exception_wrapper& /* e */) { count++; });
   auto f = p.getFuture();
   f.cancel();
   f.cancel();
@@ -77,40 +77,9 @@ TEST(Interrupt, secondInterruptNoop) {
 TEST(Interrupt, withinTimedOut) {
   Promise<int> p;
   Baton<> done;
-  p.setInterruptHandler([&](const exception_wrapper& e) { done.post(); });
+  p.setInterruptHandler([&](const exception_wrapper& /* e */) { done.post(); });
   p.getFuture().within(std::chrono::milliseconds(1));
   // Give it 100ms to time out and call the interrupt handler
   auto t = std::chrono::steady_clock::now() + std::chrono::milliseconds(100);
   EXPECT_TRUE(done.timed_wait(t));
 }
-
-class DummyTimeKeeper : public Timekeeper {
- public:
-  explicit DummyTimeKeeper() : interrupted() {}
-
-  Future<Unit> after(Duration) override {
-    promise.setInterruptHandler(
-      [this](const exception_wrapper& e) {
-        EXPECT_THROW(e.throwException(), CancelTimer);
-        interrupted.post();
-      }
-    );
-    return promise.getFuture();
-  }
-
-  Baton<> interrupted;
-
- private:
-  Promise<Unit> promise;
-};
-
-TEST(Interrupt, withinCancelTimer) {
-  DummyTimeKeeper tk;
-  Promise<int> p;
-  Baton<> done;
-  p.getFuture().within(std::chrono::milliseconds(10), TimedOut(), &tk);
-  p.setValue(1); // this should cancel the timer
-  // Give it 100ms to interrupt the timer Future
-  auto t = std::chrono::steady_clock::now() + std::chrono::milliseconds(100);
-  EXPECT_TRUE(tk.interrupted.timed_wait(t));
-}