987 |
14 Dec 09 |
peter |
// $Id$ |
987 |
14 Dec 09 |
peter |
2 |
|
987 |
14 Dec 09 |
peter |
3 |
/* |
1635 |
30 Mar 23 |
peter |
Copyright (C) 2009, 2010, 2015, 2023 Peter Johansson |
987 |
14 Dec 09 |
peter |
5 |
|
987 |
14 Dec 09 |
peter |
This file is part of svndigest, http://dev.thep.lu.se/svndigest |
987 |
14 Dec 09 |
peter |
7 |
|
987 |
14 Dec 09 |
peter |
svndigest is free software; you can redistribute it and/or modify it |
987 |
14 Dec 09 |
peter |
under the terms of the GNU General Public License as published by |
987 |
14 Dec 09 |
peter |
the Free Software Foundation; either version 3 of the License, or |
987 |
14 Dec 09 |
peter |
(at your option) any later version. |
987 |
14 Dec 09 |
peter |
12 |
|
987 |
14 Dec 09 |
peter |
svndigest is distributed in the hope that it will be useful, but |
987 |
14 Dec 09 |
peter |
WITHOUT ANY WARRANTY; without even the implied warranty of |
987 |
14 Dec 09 |
peter |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
987 |
14 Dec 09 |
peter |
General Public License for more details. |
987 |
14 Dec 09 |
peter |
17 |
|
987 |
14 Dec 09 |
peter |
You should have received a copy of the GNU General Public License |
987 |
14 Dec 09 |
peter |
along with svndigest. If not, see <http://www.gnu.org/licenses/>. |
987 |
14 Dec 09 |
peter |
20 |
*/ |
987 |
14 Dec 09 |
peter |
21 |
|
1619 |
12 Mar 23 |
peter |
22 |
#include <config.h> |
1619 |
12 Mar 23 |
peter |
23 |
|
987 |
14 Dec 09 |
peter |
24 |
#include "Suite.h" |
987 |
14 Dec 09 |
peter |
25 |
|
1119 |
04 Jul 10 |
peter |
26 |
#include "lib/HtmlStream.h" |
987 |
14 Dec 09 |
peter |
27 |
|
987 |
14 Dec 09 |
peter |
28 |
#include <sstream> |
987 |
14 Dec 09 |
peter |
29 |
|
987 |
14 Dec 09 |
peter |
30 |
using namespace theplu::svndigest; |
987 |
14 Dec 09 |
peter |
31 |
|
987 |
14 Dec 09 |
peter |
32 |
void test_stream(std::string, std::string, test::Suite&); |
987 |
14 Dec 09 |
peter |
33 |
|
987 |
14 Dec 09 |
peter |
34 |
int main(int argc, char* argv[]) |
987 |
14 Dec 09 |
peter |
35 |
{ |
987 |
14 Dec 09 |
peter |
36 |
test::Suite suite(argc, argv); |
987 |
14 Dec 09 |
peter |
37 |
|
987 |
14 Dec 09 |
peter |
38 |
test_stream("\n", "<br />", suite); |
987 |
14 Dec 09 |
peter |
39 |
test_stream("<", "<", suite); |
987 |
14 Dec 09 |
peter |
40 |
test_stream(">", ">", suite); |
987 |
14 Dec 09 |
peter |
41 |
test_stream("&", "&", suite); |
987 |
14 Dec 09 |
peter |
42 |
|
1162 |
13 Aug 10 |
peter |
43 |
return suite.exit_status(); |
987 |
14 Dec 09 |
peter |
44 |
} |
987 |
14 Dec 09 |
peter |
45 |
|
987 |
14 Dec 09 |
peter |
46 |
void test_stream(std::string in, std::string correct, test::Suite& suite) |
987 |
14 Dec 09 |
peter |
47 |
{ |
987 |
14 Dec 09 |
peter |
48 |
std::ostringstream out; |
987 |
14 Dec 09 |
peter |
49 |
HtmlStream hs(out); |
987 |
14 Dec 09 |
peter |
50 |
hs << in; |
987 |
14 Dec 09 |
peter |
51 |
if (out.str() != correct) { |
987 |
14 Dec 09 |
peter |
52 |
suite.out() << in << " -> " << out.str() << "\n"; |
987 |
14 Dec 09 |
peter |
53 |
suite.out() << "error: expected `" << correct << "'\n"; |
987 |
14 Dec 09 |
peter |
54 |
suite.add(false); |
987 |
14 Dec 09 |
peter |
55 |
} |
1571 |
05 Feb 15 |
peter |
56 |
|
1571 |
05 Feb 15 |
peter |
// check that we can use stream 'out' directly without and that the |
1571 |
05 Feb 15 |
peter |
// output is not HTMLized |
1571 |
05 Feb 15 |
peter |
59 |
out << in; |
1571 |
05 Feb 15 |
peter |
60 |
if (out.str() != correct+in) { |
1571 |
05 Feb 15 |
peter |
61 |
suite.out() << "error incorrect behaviour of base stream: "; |
1571 |
05 Feb 15 |
peter |
62 |
suite.out() << "output: '" << out.str() << "'; "; |
1571 |
05 Feb 15 |
peter |
63 |
suite.out() << "expected '" << correct+in << "'\n"; |
1571 |
05 Feb 15 |
peter |
64 |
suite.add(false); |
1571 |
05 Feb 15 |
peter |
65 |
} |
987 |
14 Dec 09 |
peter |
66 |
} |