]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/tr1/2_general_utilities/shared_ptr/observers/bool_conv.cc
Remove trailing whitespace from libstdc++-v3 files
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / tr1 / 2_general_utilities / shared_ptr / observers / bool_conv.cc
CommitLineData
818ab71a 1// Copyright (C) 2005-2016 Free Software Foundation, Inc.
7dfded91
JW
2//
3// This file is part of the GNU ISO C++ Library. This library is free
4// software; you can redistribute it and/or modify it under the
5// terms of the GNU General Public License as published by the
748086b7 6// Free Software Foundation; either version 3, or (at your option)
7dfded91
JW
7// any later version.
8
9// This library is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13
14// You should have received a copy of the GNU General Public License along
748086b7
JJ
15// with this library; see the file COPYING3. If not see
16// <http://www.gnu.org/licenses/>.
7dfded91
JW
17
18// TR1 2.2.2 Template class shared_ptr [tr.util.smartptr.shared]
19
20#include <tr1/memory>
21#include <testsuite_hooks.h>
22
23struct A { };
24
25// 2.2.3.5 shared_ptr observers [tr.util.smartptr.shared.obs]
26
27// conversion to bool
28int
29test01()
30{
31 bool test __attribute__((unused)) = true;
32
33 const std::tr1::shared_ptr<A> p1;
f641b2d6 34 VERIFY( bool(p1) == false );
7dfded91 35 const std::tr1::shared_ptr<A> p2(p1);
f641b2d6 36 VERIFY( bool(p2) == false );
7dfded91
JW
37
38 return 0;
39}
40
41int
42test02()
43{
44 bool test __attribute__((unused)) = true;
45
46 std::tr1::shared_ptr<A> p1(new A);
47 VERIFY( p1 );
48 std::tr1::shared_ptr<A> p2(p1);
49 VERIFY( p2 );
50 p1.reset();
51 VERIFY( !p1 );
52 VERIFY( p2 );
53
54 return 0;
55}
56
57int
58test03()
59{
60 bool test __attribute__((unused)) = true;
61
62 std::tr1::shared_ptr<A> p1(new A);
63 std::tr1::shared_ptr<A> p2(p1);
64 p2.reset(new A);
65 VERIFY( p1 );
66 VERIFY( p2 );
67
68 return 0;
69}
70
71
f92ab29f 72int
7dfded91
JW
73main()
74{
75 test01();
76 test02();
77 test03();
78 return 0;
79}