From 42f4cd7c92f086c89440f6adf47c5bef34e080bb Mon Sep 17 00:00:00 2001 From: Dave Watson Date: Wed, 18 Feb 2015 09:28:09 -0800 Subject: [PATCH] some moar unittests 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 | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/folly/futures/test/ExecutorTest.cpp b/folly/futures/test/ExecutorTest.cpp index bda05b4d..aa0748b6 100644 --- a/folly/futures/test/ExecutorTest.cpp +++ b/folly/futures/test/ExecutorTest.cpp @@ -160,3 +160,32 @@ TEST(Executor, RunnablePtr) { x.addPtr(fnp); EXPECT_EQ(counter, 1); } + +TEST(Executor, ThrowableThen) { + InlineExecutor x; + auto f = Future().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().via(&x).activate().then([](){ + return; + }); + f.value(); + EXPECT_TRUE(false); + } catch(...) { + // via() should throw + return; + } +} -- 2.34.1