3152 |
23 Dec 13 |
peter |
// $Id$ |
3152 |
23 Dec 13 |
peter |
2 |
|
3152 |
23 Dec 13 |
peter |
3 |
/* |
3152 |
23 Dec 13 |
peter |
Copyright (C) 2013 Peter Johansson |
3152 |
23 Dec 13 |
peter |
5 |
|
3152 |
23 Dec 13 |
peter |
This file is part of the yat library, http://dev.thep.lu.se/yat |
3152 |
23 Dec 13 |
peter |
7 |
|
3152 |
23 Dec 13 |
peter |
The yat library is free software; you can redistribute it and/or |
3152 |
23 Dec 13 |
peter |
modify it under the terms of the GNU General Public License as |
3152 |
23 Dec 13 |
peter |
published by the Free Software Foundation; either version 3 of the |
3152 |
23 Dec 13 |
peter |
License, or (at your option) any later version. |
3152 |
23 Dec 13 |
peter |
12 |
|
3152 |
23 Dec 13 |
peter |
The yat library is distributed in the hope that it will be useful, |
3152 |
23 Dec 13 |
peter |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
3152 |
23 Dec 13 |
peter |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
3152 |
23 Dec 13 |
peter |
General Public License for more details. |
3152 |
23 Dec 13 |
peter |
17 |
|
3152 |
23 Dec 13 |
peter |
You should have received a copy of the GNU General Public License |
3152 |
23 Dec 13 |
peter |
along with yat. If not, see <http://www.gnu.org/licenses/>. |
3152 |
23 Dec 13 |
peter |
20 |
*/ |
3152 |
23 Dec 13 |
peter |
21 |
|
3152 |
23 Dec 13 |
peter |
22 |
#include <config.h> |
3152 |
23 Dec 13 |
peter |
23 |
|
3152 |
23 Dec 13 |
peter |
24 |
#include "Suite.h" |
3152 |
23 Dec 13 |
peter |
25 |
|
3152 |
23 Dec 13 |
peter |
26 |
#include "yat/utility/OstreamIterator.h" |
3152 |
23 Dec 13 |
peter |
27 |
|
3152 |
23 Dec 13 |
peter |
28 |
#include <algorithm> |
3152 |
23 Dec 13 |
peter |
29 |
#include <istream> |
3152 |
23 Dec 13 |
peter |
30 |
#include <sstream> |
3152 |
23 Dec 13 |
peter |
31 |
#include <string> |
3152 |
23 Dec 13 |
peter |
32 |
#include <vector> |
3152 |
23 Dec 13 |
peter |
33 |
|
3152 |
23 Dec 13 |
peter |
34 |
using namespace theplu::yat; |
3152 |
23 Dec 13 |
peter |
35 |
|
3152 |
23 Dec 13 |
peter |
36 |
int main( int argc, char* argv[]) |
3152 |
23 Dec 13 |
peter |
37 |
{ |
3152 |
23 Dec 13 |
peter |
38 |
test::Suite suite(argc, argv); |
3152 |
23 Dec 13 |
peter |
39 |
|
3152 |
23 Dec 13 |
peter |
40 |
std::ostringstream os; |
3152 |
23 Dec 13 |
peter |
41 |
using utility::OstreamIterator; |
3152 |
23 Dec 13 |
peter |
42 |
std::vector<int> x; |
3152 |
23 Dec 13 |
peter |
43 |
x.push_back(0); |
3152 |
23 Dec 13 |
peter |
44 |
x.push_back(12); |
3152 |
23 Dec 13 |
peter |
45 |
x.push_back(42); |
3152 |
23 Dec 13 |
peter |
46 |
std::copy(x.begin(), x.end(), OstreamIterator<int>(os, ":")); |
3152 |
23 Dec 13 |
peter |
47 |
suite.out() << "os: '" << os.str() << "'\n"; |
3152 |
23 Dec 13 |
peter |
48 |
if (os.str()!="0:12:42") { |
3152 |
23 Dec 13 |
peter |
49 |
suite.add(false); |
3152 |
23 Dec 13 |
peter |
50 |
suite.err() << "error\n"; |
3152 |
23 Dec 13 |
peter |
51 |
} |
3152 |
23 Dec 13 |
peter |
52 |
|
3152 |
23 Dec 13 |
peter |
53 |
std::ostringstream os2; |
3152 |
23 Dec 13 |
peter |
54 |
OstreamIterator<int> out(os2, ":"); |
3152 |
23 Dec 13 |
peter |
55 |
std::copy(x.begin(), x.begin()+1, out); |
3152 |
23 Dec 13 |
peter |
56 |
os2 << ":"; |
3152 |
23 Dec 13 |
peter |
57 |
std::copy(x.begin()+1, x.end(), out); |
3152 |
23 Dec 13 |
peter |
58 |
suite.out() << "os: '" << os2.str() << "'\n"; |
3152 |
23 Dec 13 |
peter |
59 |
if (os2.str()!="0:12:42") { |
3152 |
23 Dec 13 |
peter |
60 |
suite.add(false); |
3152 |
23 Dec 13 |
peter |
61 |
suite.err() << "error\n"; |
3152 |
23 Dec 13 |
peter |
62 |
} |
3152 |
23 Dec 13 |
peter |
63 |
|
3152 |
23 Dec 13 |
peter |
64 |
suite.test_output_iterator(out); |
3152 |
23 Dec 13 |
peter |
65 |
|
3152 |
23 Dec 13 |
peter |
66 |
return suite.return_value(); |
3152 |
23 Dec 13 |
peter |
67 |
} |