source: trunk/test/iterator_test.cc @ 880

Last change on this file since 880 was 880, checked in by Peter, 16 years ago

refs #244

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.8 KB
Line 
1// $Id: iterator_test.cc 880 2007-09-21 23:43:22Z peter $
2
3/*
4  Copyright (C) 2007 Peter Johansson
5
6  This file is part of the yat library, http://trac.thep.lu.se/trac/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/classifier/DataLookup1D.h"
25
26#include "yat/utility/constIterator.h"
27#include "yat/utility/Iterator.h"
28#include "yat/utility/vector.h"
29
30#include <algorithm>
31#include <fstream>
32
33using namespace theplu::yat;
34
35int main(const int argc,const char* argv[])
36{ 
37  std::ostream* message;
38  if (argc>1 && argv[1]==std::string("-v"))
39    message = &std::cerr;
40  else {
41    message = new std::ofstream("/dev/null");
42    if (argc>1)
43      std::cout << "iterator_test -v : for printing extra "  << "information\n";
44  }
45  *message << "testing iterator" << std::endl;
46  bool ok = true;
47
48  utility::vector vec(12);
49  classifier::DataLookup1D lookup(vec);
50  utility::vector::iterator begin=vec.begin();
51  utility::vector::iterator end=vec.end();
52  std::sort(begin, end);
53  classifier::DataLookup1D::const_iterator lbegin=lookup.begin();
54  classifier::DataLookup1D::const_iterator lend=lookup.end();
55 
56  std::copy(lbegin, lend, begin);
57  std::copy(begin, end, begin);
58  std::sort(begin, end);
59
60  if (!ok)
61    *message << "iterator test failed" << std::endl;
62
63  return (ok ? 0 : -1);
64}
Note: See TracBrowser for help on using the repository browser.