some moar unittests
authorDave Watson <davejwatson@fb.com>
Wed, 18 Feb 2015 17:28:09 +0000 (09:28 -0800)
committerAlecs King <int@fb.com>
Tue, 3 Mar 2015 03:23:27 +0000 (19:23 -0800)
Summary: from discussion

Test Plan: unit tests

Reviewed By: hans@fb.com

Subscribers: doug, folly-diffs@, jsedgwick, yfeldblum

FB internal diff: D1829282

Signature: t1:1829282:1423180907:3630dac1378750b05f316c672fbbd71138d2bc0a

folly/futures/test/ExecutorTest.cpp

index bda05b4db45a391377b2ff76ee56d5c05e770876..aa0748b6d86af9f9c53bb518fe20f756159391c9 100644 (file)
@@ -160,3 +160,32 @@ TEST(Executor, RunnablePtr) {
   x.addPtr(fnp);
   EXPECT_EQ(counter, 1);
 }
+
+TEST(Executor, ThrowableThen) {
+  InlineExecutor x;
+  auto f = Future<void>().via(&x).then([](){
+    throw std::runtime_error("Faildog");
+  });
+  EXPECT_THROW(f.value(), std::exception);
+}
+
+class CrappyExecutor : public Executor {
+ public:
+  void add(Func f) override {
+    throw std::runtime_error("bad");
+  }
+};
+
+TEST(Executor, CrappyExecutor) {
+  CrappyExecutor x;
+  try {
+    auto f = Future<void>().via(&x).activate().then([](){
+      return;
+    });
+    f.value();
+    EXPECT_TRUE(false);
+  } catch(...) {
+    // via() should throw
+    return;
+  }
+}