309 |
12 May 07 |
peter |
// $Id$ |
309 |
12 May 07 |
peter |
2 |
|
309 |
12 May 07 |
peter |
3 |
/* |
1635 |
30 Mar 23 |
peter |
Copyright (C) 2007 Peter Johansson |
1635 |
30 Mar 23 |
peter |
Copyright (C) 2008 Jari Häkkinen, Peter Johansson |
1635 |
30 Mar 23 |
peter |
Copyright (C) 2009, 2010, 2023 Peter Johansson |
309 |
12 May 07 |
peter |
7 |
|
687 |
04 Aug 08 |
peter |
This file is part of svndigest, http://dev.thep.lu.se/svndigest |
309 |
12 May 07 |
peter |
9 |
|
309 |
12 May 07 |
peter |
svndigest is free software; you can redistribute it and/or modify it |
309 |
12 May 07 |
peter |
under the terms of the GNU General Public License as published by |
693 |
11 Sep 08 |
jari |
the Free Software Foundation; either version 3 of the License, or |
309 |
12 May 07 |
peter |
(at your option) any later version. |
309 |
12 May 07 |
peter |
14 |
|
309 |
12 May 07 |
peter |
svndigest is distributed in the hope that it will be useful, but |
309 |
12 May 07 |
peter |
WITHOUT ANY WARRANTY; without even the implied warranty of |
309 |
12 May 07 |
peter |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
309 |
12 May 07 |
peter |
General Public License for more details. |
309 |
12 May 07 |
peter |
19 |
|
309 |
12 May 07 |
peter |
You should have received a copy of the GNU General Public License |
693 |
11 Sep 08 |
jari |
along with svndigest. If not, see <http://www.gnu.org/licenses/>. |
309 |
12 May 07 |
peter |
22 |
*/ |
309 |
12 May 07 |
peter |
23 |
|
1619 |
12 Mar 23 |
peter |
24 |
#include <config.h> |
1619 |
12 Mar 23 |
peter |
25 |
|
1163 |
13 Aug 10 |
peter |
26 |
#include "Suite.h" |
1163 |
13 Aug 10 |
peter |
27 |
|
1119 |
04 Jul 10 |
peter |
28 |
#include "lib/Configuration.h" |
1119 |
04 Jul 10 |
peter |
29 |
#include "lib/HtmlStream.h" |
1119 |
04 Jul 10 |
peter |
30 |
#include "lib/html_utility.h" |
1119 |
04 Jul 10 |
peter |
31 |
#include "lib/Trac.h" |
309 |
12 May 07 |
peter |
32 |
|
309 |
12 May 07 |
peter |
33 |
#include <fstream> |
309 |
12 May 07 |
peter |
34 |
#include <iostream> |
309 |
12 May 07 |
peter |
35 |
#include <sstream> |
309 |
12 May 07 |
peter |
36 |
#include <string> |
309 |
12 May 07 |
peter |
37 |
|
309 |
12 May 07 |
peter |
38 |
bool test(std::string mess, std::string href, std::ostream&); |
768 |
31 Jan 09 |
peter |
39 |
bool test_no_anchor(std::string str, std::ostream&); |
309 |
12 May 07 |
peter |
40 |
|
1163 |
13 Aug 10 |
peter |
41 |
int main(int argc, char* argv[]) |
309 |
12 May 07 |
peter |
42 |
{ |
1163 |
13 Aug 10 |
peter |
43 |
using namespace theplu; |
1163 |
13 Aug 10 |
peter |
44 |
svndigest::test::Suite suite(argc, argv); |
309 |
12 May 07 |
peter |
45 |
bool ok=true; |
309 |
12 May 07 |
peter |
46 |
std::ostream& my_out(std::cout); |
309 |
12 May 07 |
peter |
47 |
|
1163 |
13 Aug 10 |
peter |
48 |
using svndigest::Configuration; |
309 |
12 May 07 |
peter |
// faking a config file |
309 |
12 May 07 |
peter |
50 |
Configuration& conf = Configuration::instance(); |
309 |
12 May 07 |
peter |
51 |
std::stringstream ss; |
309 |
12 May 07 |
peter |
52 |
ss << "[trac]\ntrac-root = http://trac.domain.org/\n"; |
309 |
12 May 07 |
peter |
53 |
conf.load(ss); |
309 |
12 May 07 |
peter |
54 |
|
309 |
12 May 07 |
peter |
55 |
|
309 |
12 May 07 |
peter |
56 |
ok &= test("r123", conf.trac_root()+"changeset/123", my_out); |
309 |
12 May 07 |
peter |
57 |
ok &= test("[123]", conf.trac_root()+"changeset/123", my_out); |
309 |
12 May 07 |
peter |
58 |
ok &= test("changeset:123", conf.trac_root()+"changeset/123", my_out); |
309 |
12 May 07 |
peter |
59 |
ok &= test("comment:ticket:123:1", |
309 |
12 May 07 |
peter |
60 |
conf.trac_root()+"ticket/123#comment:1", my_out); |
309 |
12 May 07 |
peter |
61 |
ok &= test("diff:trunk@12:123", conf.trac_root()+ |
400 |
28 Jun 07 |
peter |
62 |
"changeset?new=123&new_path=trunk&"+ |
400 |
28 Jun 07 |
peter |
63 |
"old=12&old_path=trunk", |
309 |
12 May 07 |
peter |
64 |
my_out); |
309 |
12 May 07 |
peter |
65 |
ok &= test("diff:tags/1.0", conf.trac_root()+ |
400 |
28 Jun 07 |
peter |
66 |
"changeset?new_path=tags/1.0&old_path=tags/1.0", |
309 |
12 May 07 |
peter |
67 |
my_out); |
309 |
12 May 07 |
peter |
68 |
ok &= test("diff:tags/1.0//tags/1.0.1", conf.trac_root()+ |
400 |
28 Jun 07 |
peter |
69 |
"changeset?new_path=tags/1.0.1&old_path=tags/1.0", |
309 |
12 May 07 |
peter |
70 |
my_out); |
309 |
12 May 07 |
peter |
71 |
ok &= test("diff:tags/1.0@123//trunk@236", conf.trac_root()+ |
400 |
28 Jun 07 |
peter |
72 |
"changeset?new=236&new_path=trunk&"+ |
400 |
28 Jun 07 |
peter |
73 |
"old=123&old_path=tags/1.0", |
309 |
12 May 07 |
peter |
74 |
my_out); |
400 |
28 Jun 07 |
peter |
75 |
ok &= test("r123:236", conf.trac_root()+"log/?rev=236&stop_rev=123", |
400 |
28 Jun 07 |
peter |
76 |
my_out); |
400 |
28 Jun 07 |
peter |
77 |
ok &= test("[123:236]",conf.trac_root()+"log/?rev=236&stop_rev=123", |
400 |
28 Jun 07 |
peter |
78 |
my_out); |
309 |
12 May 07 |
peter |
79 |
ok &= test("log:trunk@123:236", |
400 |
28 Jun 07 |
peter |
80 |
conf.trac_root()+"log/trunk?rev=236&stop_rev=123", my_out); |
309 |
12 May 07 |
peter |
81 |
ok &= test("milestone:1.0", conf.trac_root()+"milestone/1.0", my_out); |
309 |
12 May 07 |
peter |
82 |
ok &= test("source:trunk", conf.trac_root()+"browser/trunk", my_out); |
309 |
12 May 07 |
peter |
83 |
ok &= test("source:trunk@123", conf.trac_root()+"browser/trunk?rev=123", |
309 |
12 May 07 |
peter |
84 |
my_out); |
309 |
12 May 07 |
peter |
85 |
ok &= test("source:trunk@123#L3", |
309 |
12 May 07 |
peter |
86 |
conf.trac_root()+"browser/trunk?rev=123#L3", my_out); |
309 |
12 May 07 |
peter |
87 |
ok &= test("#65", conf.trac_root()+"ticket/65", my_out); |
309 |
12 May 07 |
peter |
88 |
ok &= test("ticket:65", conf.trac_root()+"ticket/65", my_out); |
768 |
31 Jan 09 |
peter |
89 |
ok &= test_no_anchor("Container2D", my_out); |
768 |
31 Jan 09 |
peter |
90 |
ok &= test_no_anchor("r2b", my_out); |
768 |
31 Jan 09 |
peter |
91 |
ok &= test_no_anchor("ar2", my_out); |
768 |
31 Jan 09 |
peter |
92 |
ok &= test_no_anchor("2r2", my_out); |
768 |
31 Jan 09 |
peter |
93 |
ok &= test_no_anchor("r2r3", my_out); |
768 |
31 Jan 09 |
peter |
94 |
ok &= test_no_anchor("ar2:3", my_out); |
768 |
31 Jan 09 |
peter |
95 |
ok &= test_no_anchor("r2:3a", my_out); |
309 |
12 May 07 |
peter |
96 |
|
1162 |
13 Aug 10 |
peter |
97 |
suite.add(ok); |
1162 |
13 Aug 10 |
peter |
98 |
return suite.exit_status(); |
309 |
12 May 07 |
peter |
99 |
} |
309 |
12 May 07 |
peter |
100 |
|
309 |
12 May 07 |
peter |
101 |
bool test(std::string mess, std::string href, std::ostream& out) |
309 |
12 May 07 |
peter |
102 |
{ |
309 |
12 May 07 |
peter |
103 |
using namespace theplu::svndigest; |
309 |
12 May 07 |
peter |
104 |
std::stringstream ss; |
309 |
12 May 07 |
peter |
105 |
HtmlStream html(ss); |
309 |
12 May 07 |
peter |
106 |
Trac trac(html); |
317 |
17 May 07 |
peter |
107 |
trac.print(mess,80); |
309 |
12 May 07 |
peter |
108 |
if (ss.str()==anchor(href, mess)) |
309 |
12 May 07 |
peter |
109 |
return true; |
309 |
12 May 07 |
peter |
110 |
out << "error:\n"; |
309 |
12 May 07 |
peter |
111 |
out << " message: " << mess << std::endl; |
309 |
12 May 07 |
peter |
112 |
out << " trac generates output:\n " << ss.str() << std::endl; |
309 |
12 May 07 |
peter |
113 |
out << " expected:\n " << anchor(href, mess) << std::endl; |
309 |
12 May 07 |
peter |
114 |
return false; |
309 |
12 May 07 |
peter |
115 |
} |
309 |
12 May 07 |
peter |
116 |
|
768 |
31 Jan 09 |
peter |
117 |
bool test_no_anchor(std::string str, std::ostream& os) |
768 |
31 Jan 09 |
peter |
118 |
{ |
768 |
31 Jan 09 |
peter |
119 |
using namespace theplu::svndigest; |
768 |
31 Jan 09 |
peter |
120 |
std::stringstream ss; |
768 |
31 Jan 09 |
peter |
121 |
HtmlStream html(ss); |
768 |
31 Jan 09 |
peter |
122 |
Trac trac(html); |
768 |
31 Jan 09 |
peter |
123 |
trac.print(str,80); |
768 |
31 Jan 09 |
peter |
124 |
if (ss.str()!=str) { |
768 |
31 Jan 09 |
peter |
125 |
os << "error:\n"; |
768 |
31 Jan 09 |
peter |
126 |
os << " message: " << str << std::endl; |
768 |
31 Jan 09 |
peter |
127 |
os << " trac generates output:\n " << ss.str() << std::endl; |
768 |
31 Jan 09 |
peter |
128 |
os << " expected:\n " << str << std::endl; |
768 |
31 Jan 09 |
peter |
129 |
return false; |
768 |
31 Jan 09 |
peter |
130 |
} |
768 |
31 Jan 09 |
peter |
131 |
return true; |
768 |
31 Jan 09 |
peter |
132 |
} |