1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // <memory> 11 12 // unique_ptr 13 14 // test get 15 16 #include <memory> 17 #include <cassert> 18 19 #include "test_macros.h" 20 #include "unique_ptr_test_helper.h" 21 22 template <bool IsArray> test_basic()23void test_basic() { 24 typedef typename std::conditional<IsArray, int[], int>::type VT; 25 typedef const VT CVT; 26 { 27 typedef std::unique_ptr<VT> U; 28 int* p = newValue<VT>(1); 29 U s(p); 30 U const& sc = s; 31 ASSERT_SAME_TYPE(decltype(s.get()), int*); 32 ASSERT_SAME_TYPE(decltype(sc.get()), int*); 33 assert(s.get() == p); 34 assert(sc.get() == s.get()); 35 } 36 { 37 typedef std::unique_ptr<CVT> U; 38 const int* p = newValue<VT>(1); 39 U s(p); 40 U const& sc = s; 41 ASSERT_SAME_TYPE(decltype(s.get()), const int*); 42 ASSERT_SAME_TYPE(decltype(sc.get()), const int*); 43 assert(s.get() == p); 44 assert(sc.get() == s.get()); 45 } 46 } 47 main()48int main() { 49 test_basic</*IsArray*/ false>(); 50 test_basic<true>(); 51 } 52