1 //===----------------------------------------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 // <memory> 10 11 // unique_ptr 12 13 // test get 14 15 #include <memory> 16 #include <cassert> 17 18 #include "test_macros.h" 19 #include "unique_ptr_test_helper.h" 20 21 template <bool IsArray> test_basic()22void test_basic() { 23 typedef typename std::conditional<IsArray, int[], int>::type VT; 24 typedef const VT CVT; 25 { 26 typedef std::unique_ptr<VT> U; 27 int* p = newValue<VT>(1); 28 U s(p); 29 U const& sc = s; 30 ASSERT_SAME_TYPE(decltype(s.get()), int*); 31 ASSERT_SAME_TYPE(decltype(sc.get()), int*); 32 assert(s.get() == p); 33 assert(sc.get() == s.get()); 34 } 35 { 36 typedef std::unique_ptr<CVT> U; 37 const int* p = newValue<VT>(1); 38 U s(p); 39 U const& sc = s; 40 ASSERT_SAME_TYPE(decltype(s.get()), const int*); 41 ASSERT_SAME_TYPE(decltype(sc.get()), const int*); 42 assert(s.get() == p); 43 assert(sc.get() == s.get()); 44 } 45 } 46 main(int,char **)47int main(int, char**) { 48 test_basic</*IsArray*/ false>(); 49 test_basic<true>(); 50 51 return 0; 52 } 53