summaryrefslogtreecommitdiff
path: root/unittests/ADT/FunctionRefTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'unittests/ADT/FunctionRefTest.cpp')
-rw-r--r--unittests/ADT/FunctionRefTest.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/unittests/ADT/FunctionRefTest.cpp b/unittests/ADT/FunctionRefTest.cpp
index 075d9a070df72..b7ef7d79e5f99 100644
--- a/unittests/ADT/FunctionRefTest.cpp
+++ b/unittests/ADT/FunctionRefTest.cpp
@@ -14,6 +14,20 @@ using namespace llvm;
namespace {
+// Ensure that there is a default constructor and we can test for a null
+// function_ref.
+TEST(FunctionRefTest, Null) {
+ function_ref<int()> F;
+ EXPECT_FALSE(F);
+
+ auto L = [] { return 1; };
+ F = L;
+ EXPECT_TRUE(F);
+
+ F = {};
+ EXPECT_FALSE(F);
+}
+
// Ensure that copies of a function_ref copy the underlying state rather than
// causing one function_ref to chain to the next.
TEST(FunctionRefTest, Copy) {