From: Subodh Iyengar Date: Thu, 16 Nov 2017 01:59:20 +0000 (-0800) Subject: Add unit test for timeout=0 X-Git-Tag: v2017.11.20.00~8 X-Git-Url: http://plrg.eecs.uci.edu/git/?p=folly.git;a=commitdiff_plain;h=54b16a23784d48f1a3b56ff0c33bdf7fdfe46355;hp=76cae471730faf4fcdaa4b3a6df35727910932f7 Add unit test for timeout=0 Summary: Add unit test for immediate timeout since we're using it in a few places. Reviewed By: yfeldblum Differential Revision: D6327012 fbshipit-source-id: ea80763d080b06e2a43277118d3147dc8016f348 --- diff --git a/folly/io/async/test/AsyncTimeoutTest.cpp b/folly/io/async/test/AsyncTimeoutTest.cpp index 629d6786..1d7c04fe 100644 --- a/folly/io/async/test/AsyncTimeoutTest.cpp +++ b/folly/io/async/test/AsyncTimeoutTest.cpp @@ -53,6 +53,20 @@ TEST(AsyncTimeout, schedule) { EXPECT_EQ(expected, value); } +TEST(AsyncTimeout, schedule_immediate) { + int value = 0; + int const expected = 10; + EventBase manager; + + auto observer = AsyncTimeout::schedule( + std::chrono::milliseconds(0), manager, [&]() noexcept { + value = expected; + }); + + manager.loop(); + EXPECT_EQ(expected, value); +} + TEST(AsyncTimeout, cancel_make) { int value = 0; int const expected = 10;