[987] | 1 | // $Id: htmlstream_test.cc 1162 2010-08-13 17:30:03Z peter $ |
---|
| 2 | |
---|
| 3 | /* |
---|
[1127] | 4 | Copyright (C) 2009, 2010 Peter Johansson |
---|
[987] | 5 | |
---|
| 6 | This file is part of svndigest, http://dev.thep.lu.se/svndigest |
---|
| 7 | |
---|
| 8 | svndigest is free software; you can redistribute it and/or modify it |
---|
| 9 | under the terms of the GNU General Public License as published by |
---|
| 10 | the Free Software Foundation; either version 3 of the License, or |
---|
| 11 | (at your option) any later version. |
---|
| 12 | |
---|
| 13 | svndigest is distributed in the hope that it will be useful, but |
---|
| 14 | 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 svndigest. If not, see <http://www.gnu.org/licenses/>. |
---|
| 20 | */ |
---|
| 21 | |
---|
| 22 | #include "Suite.h" |
---|
| 23 | |
---|
[1119] | 24 | #include "lib/HtmlStream.h" |
---|
[987] | 25 | |
---|
| 26 | #include <sstream> |
---|
| 27 | |
---|
| 28 | using namespace theplu::svndigest; |
---|
| 29 | |
---|
| 30 | void test_stream(std::string, std::string, test::Suite&); |
---|
| 31 | |
---|
| 32 | int main(int argc, char* argv[]) |
---|
| 33 | { |
---|
| 34 | test::Suite suite(argc, argv); |
---|
| 35 | |
---|
| 36 | test_stream("\n", "<br />", suite); |
---|
| 37 | test_stream("<", "<", suite); |
---|
| 38 | test_stream(">", ">", suite); |
---|
| 39 | test_stream("&", "&", suite); |
---|
| 40 | |
---|
[1162] | 41 | return suite.exit_status(); |
---|
[987] | 42 | } |
---|
| 43 | |
---|
| 44 | void test_stream(std::string in, std::string correct, test::Suite& suite) |
---|
| 45 | { |
---|
| 46 | std::ostringstream out; |
---|
| 47 | HtmlStream hs(out); |
---|
| 48 | hs << in; |
---|
| 49 | if (out.str() != correct) { |
---|
| 50 | suite.out() << in << " -> " << out.str() << "\n"; |
---|
| 51 | suite.out() << "error: expected `" << correct << "'\n"; |
---|
| 52 | suite.add(false); |
---|
| 53 | } |
---|
| 54 | } |
---|