source: trunk/test/smart_ptr_test.cc @ 1121

Last change on this file since 1121 was 1121, checked in by Peter, 14 years ago

fixes #308

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.7 KB
Line 
1// $Id: smart_ptr_test.cc 1121 2008-02-22 15:29:56Z peter $
2
3/*
4  Copyright (C) 2008 Peter Johansson
5
6  This file is part of the yat library, http://trac.thep.lu.se/yat
7
8  The yat library is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License as
10  published by the Free Software Foundation; either version 2 of the
11  License, or (at your option) any later version.
12
13  The yat library is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  General Public License for more details.
17
18  You should have received a copy of the GNU General Public License
19  along with this program; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21  02111-1307, USA.
22*/
23
24#include "yat/utility/SmartPtr.h"
25#include "yat/utility/Matrix.h"
26
27#include <fstream>
28#include <iostream>
29
30int main(const int argc,const char* argv[])
31
32{ 
33  using namespace theplu::yat;
34
35  std::ostream* error;
36  if (argc>1 && argv[1]==std::string("-v"))
37    error = &std::cerr;
38  else {
39    error = new std::ofstream("/dev/null");
40    if (argc>1)
41      std::cout << "smart_ptr_test -v : for printing extra information\n";
42  }
43  *error << "testing smart_ptr" << std::endl;
44
45  bool ok = true;
46
47  utility::SmartPtr<utility::Matrix> m(new utility::Matrix(10,10));
48  if (m->columns()==10){
49    utility::SmartPtr<utility::Matrix> m2(m);
50    m2 = m;
51  }
52  else
53    ok = false;
54
55  m = m;
56  utility::Matrix m2 = *m;
57
58  if (m->columns()!=10)
59    ok = false;
60
61  if(ok)
62    *error << "OK" << std::endl;
63  else
64    *error << "Failed" << std::endl;
65  if (error!=&std::cerr)
66    delete error;
67
68
69  if (ok) 
70    return 0;
71  return -1;
72
73}
Note: See TracBrowser for help on using the repository browser.