This commit was manufactured by cvs2svn to create branch
[official-gcc.git] / libstdc++-v3 / testsuite / tr1 / 2_general_utilities / memory / shared_ptr / cons / pointer.cc
blob676878234896c1ee9bcaa519d7c73f2beafb2c63
1 // Copyright (C) 2005 Free Software Foundation
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
6 // Free Software Foundation; either version 2, or (at your option)
7 // any later version.
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.
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING. If not, write to the Free
16 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
17 // USA.
19 // TR1 2.2.2 Template class shared_ptr [tr.util.smartptr.shared]
21 #include <tr1/memory>
22 #include <testsuite_hooks.h>
24 struct A { };
25 struct B : A { };
28 // 2.2.3.1 shared_ptr constructors [tr.util.smartptr.shared.const]
30 // Construction from pointer
32 int
33 test01()
35 bool test __attribute__((unused)) = true;
37 A * const a = 0;
38 std::tr1::shared_ptr<A> p(a);
39 VERIFY( p.get() == 0 );
40 VERIFY( p.use_count() == 1 );
42 return 0;
45 int
46 test02()
48 bool test __attribute__((unused)) = true;
50 A * const a = new A;
51 std::tr1::shared_ptr<A> p(a);
52 VERIFY( p.get() == a );
53 VERIFY( p.use_count() == 1 );
55 return 0;
59 int
60 test03()
62 bool test __attribute__((unused)) = true;
64 B * const b = new B;
65 std::tr1::shared_ptr<A> p(b);
66 VERIFY( p.get() == b );
67 VERIFY( p.use_count() == 1 );
69 return 0;
72 int
73 main()
75 test01();
76 test02();
77 test02();
78 return 0;