Home | History | Annotate | Download | only in ADT
      1 //===- llvm/unittest/ADT/MakeUniqueTest.cpp - make_unique unit tests ------===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is distributed under the University of Illinois Open Source
      6 // License. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 
     10 #include "llvm/ADT/STLExtras.h"
     11 #include "gtest/gtest.h"
     12 
     13 using namespace llvm;
     14 
     15 namespace {
     16 
     17 // Ensure that copies of a function_ref copy the underlying state rather than
     18 // causing one function_ref to chain to the next.
     19 TEST(FunctionRefTest, Copy) {
     20   auto A = [] { return 1; };
     21   auto B = [] { return 2; };
     22   function_ref<int()> X = A;
     23   function_ref<int()> Y = X;
     24   X = B;
     25   EXPECT_EQ(1, Y());
     26 }
     27 
     28 }
     29