From 5883ec1f1a88b33054083ca7a2a7f60d7b84a75f Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Tue, 3 Jun 2014 21:08:55 +0300 Subject: [PATCH] Add get_pointer_test. --- test/Jamfile.v2 | 2 ++ test/get_pointer_test.cpp | 50 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 test/get_pointer_test.cpp diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index e7ddce2..8746d8b 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -47,4 +47,6 @@ test-suite "core" [ run sp_typeinfo_test.cpp : : : off : sp_typeinfo_test_no_rtti ] [ run visit_each_test.cpp ] + + [ run get_pointer_test.cpp ] ; diff --git a/test/get_pointer_test.cpp b/test/get_pointer_test.cpp new file mode 100644 index 0000000..edf4037 --- /dev/null +++ b/test/get_pointer_test.cpp @@ -0,0 +1,50 @@ +// +// get_pointer_test.cpp +// +// Copyright 2014 Peter Dimov +// +// Distributed under the Boost Software License, Version 1.0. +// See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt +// + +#include +#include +#include + +struct X +{ +}; + +int main() +{ + using boost::get_pointer; + + { + X * p = new X; + BOOST_TEST( get_pointer( p ) == p ); + + delete p; + } + + { + std::auto_ptr< X > p( new X ); + BOOST_TEST( get_pointer( p ) == p.get() ); + } + +#if !defined( BOOST_NO_CXX11_SMART_PTR ) + + { + std::unique_ptr< X > p( new X ); + BOOST_TEST( get_pointer( p ) == p.get() ); + } + + { + std::shared_ptr< X > p( new X ); + BOOST_TEST( get_pointer( p ) == p.get() ); + } + +#endif + + return boost::report_errors(); +}