1// Copyright (C) 2005, 2009 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 3, or (at your option)
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
15// with this library; see the file COPYING3.  If not see
16// <http://www.gnu.org/licenses/>.
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  A() : i() {}
26  int i;
27};
28
29// 2.2.3.5 shared_ptr observers [tr.util.smartptr.shared.obs]
30
31// get
32int
33test01()
34{
35  bool test __attribute__((unused)) = true;
36
37  A * const a = new A;
38  const std::tr1::shared_ptr<A> p(a);
39  VERIFY( p.get() == a );
40
41  return 0;
42}
43
44// operator*
45int
46test02()
47{
48  bool test __attribute__((unused)) = true;
49
50  A * const a = new A;
51  const std::tr1::shared_ptr<A> p(a);
52  VERIFY( &*p == a );
53
54  return 0;
55}
56
57
58// operator->
59int
60test03()
61{
62  bool test __attribute__((unused)) = true;
63
64  A * const a = new A;
65  const std::tr1::shared_ptr<A> p(a);
66  VERIFY( &p->i == &a->i );
67
68  return 0;
69}
70
71
72int
73main()
74{
75  test01();
76  test02();
77  test03();
78  return 0;
79}
80