throwing_ptr
Smart pointers that throw on dereference if null
All Classes Namespaces Files Functions Typedefs Friends Macros
shared_ptr_ostream.cpp
Go to the documentation of this file.
1 // Copyright Claudio Bantaloukas 2017-2018.
2 // Distributed under the Boost Software License, Version 1.0.
3 // (See accompanying file LICENSE or copy at
4 // http://www.boost.org/LICENSE_1_0.txt)
5 
6 #include <catch.hpp>
7 #include <sstream>
8 #include <throwing/shared_ptr.hpp>
9 
10 TEST_CASE("operator<< prints stored ptr", "[shared_ptr][streams]") {
11  auto ptr = throwing::make_shared<int>();
12  std::stringstream ss_ptr;
13  ss_ptr << ptr.get();
14  std::stringstream ss_tptr;
15  ss_tptr << ptr;
16  REQUIRE(ss_tptr.str() == ss_ptr.str());
17 }
18 
19 TEST_CASE("operator<< prints nullptr", "[shared_ptr][streams]") {
20  throwing::shared_ptr<int> ptr;
21  std::stringstream ss_ptr;
22  ss_ptr << ptr.get();
23  std::stringstream ss_tptr;
24  ss_tptr << ptr;
25  REQUIRE(ss_tptr.str() == ss_ptr.str());
26 }
TEST_CASE("unique_ptr to array reset to convertible", "[unique_ptr][array][reset][conv.qual]")