cancel: Fix passing nullopt to constructor
It should be possible to use any of the Handle constructors in addition
to the new default constructor.
Change-Id: I384c5c8a9061d2fde4517bbd75c8b75b705ec1d3
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/test/cancel.cpp b/test/cancel.cpp
index d8c75a8..3efefb8 100644
--- a/test/cancel.cpp
+++ b/test/cancel.cpp
@@ -21,11 +21,22 @@
EXPECT_EQ(c.count, 0);
{
Cancel cancel(&c);
+ EXPECT_TRUE(cancel);
+ Cancel cancel2(std::move(cancel));
+ EXPECT_FALSE(cancel);
+ EXPECT_TRUE(cancel2);
EXPECT_EQ(c.count, 0);
}
EXPECT_EQ(c.count, 1);
}
+TEST(CancelTest, EmptyCancel)
+{
+ Cancel cancel, cancel2(std::nullopt);
+ EXPECT_FALSE(cancel);
+ EXPECT_FALSE(cancel2);
+}
+
TEST(CancelTest, AlwaysCallOnceLambda)
{
size_t ctr = 0;