556 |
16 Jan 08 |
peter |
// $Id$ |
556 |
16 Jan 08 |
peter |
2 |
|
556 |
16 Jan 08 |
peter |
3 |
/* |
978 |
12 Dec 09 |
peter |
Copyright (C) 2008 Jari Häkkinen, Peter Johansson |
1635 |
30 Mar 23 |
peter |
Copyright (C) 2009, 2010, 2011, 2023 Peter Johansson |
556 |
16 Jan 08 |
peter |
6 |
|
687 |
04 Aug 08 |
peter |
This file is part of svndigest, http://dev.thep.lu.se/svndigest |
556 |
16 Jan 08 |
peter |
8 |
|
556 |
16 Jan 08 |
peter |
svndigest is free software; you can redistribute it and/or modify it |
556 |
16 Jan 08 |
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 |
556 |
16 Jan 08 |
peter |
(at your option) any later version. |
556 |
16 Jan 08 |
peter |
13 |
|
556 |
16 Jan 08 |
peter |
svndigest is distributed in the hope that it will be useful, but |
556 |
16 Jan 08 |
peter |
WITHOUT ANY WARRANTY; without even the implied warranty of |
556 |
16 Jan 08 |
peter |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
556 |
16 Jan 08 |
peter |
General Public License for more details. |
556 |
16 Jan 08 |
peter |
18 |
|
556 |
16 Jan 08 |
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/>. |
556 |
16 Jan 08 |
peter |
21 |
*/ |
556 |
16 Jan 08 |
peter |
22 |
|
1619 |
12 Mar 23 |
peter |
23 |
#include <config.h> |
1619 |
12 Mar 23 |
peter |
24 |
|
938 |
03 Dec 09 |
peter |
25 |
#include "Suite.h" |
938 |
03 Dec 09 |
peter |
26 |
|
1119 |
04 Jul 10 |
peter |
27 |
#include "lib/Configuration.h" |
556 |
16 Jan 08 |
peter |
28 |
|
1237 |
23 Oct 10 |
peter |
29 |
#include <sstream> |
1237 |
23 Oct 10 |
peter |
30 |
|
556 |
16 Jan 08 |
peter |
31 |
namespace theplu{ |
556 |
16 Jan 08 |
peter |
32 |
namespace svndigest{ |
938 |
03 Dec 09 |
peter |
33 |
void test_codon(test::Suite&); |
996 |
28 Dec 09 |
peter |
34 |
void test_read_write(test::Suite&); |
1152 |
07 Aug 10 |
peter |
35 |
void test_props(test::Suite&); |
556 |
16 Jan 08 |
peter |
36 |
}} // end of namespace svndigest and theplu |
556 |
16 Jan 08 |
peter |
37 |
|
556 |
16 Jan 08 |
peter |
38 |
|
556 |
16 Jan 08 |
peter |
39 |
int main( int argc, char* argv[]) |
556 |
16 Jan 08 |
peter |
40 |
{ |
556 |
16 Jan 08 |
peter |
41 |
using namespace theplu::svndigest; |
938 |
03 Dec 09 |
peter |
42 |
test::Suite suite(argc, argv, false); |
556 |
16 Jan 08 |
peter |
43 |
|
938 |
03 Dec 09 |
peter |
44 |
test_codon(suite); |
996 |
28 Dec 09 |
peter |
45 |
test_read_write(suite); |
1152 |
07 Aug 10 |
peter |
46 |
test_props(suite); |
556 |
16 Jan 08 |
peter |
47 |
|
1162 |
13 Aug 10 |
peter |
48 |
return suite.exit_status(); |
556 |
16 Jan 08 |
peter |
49 |
} |
556 |
16 Jan 08 |
peter |
50 |
|
556 |
16 Jan 08 |
peter |
51 |
|
556 |
16 Jan 08 |
peter |
52 |
namespace theplu{ |
556 |
16 Jan 08 |
peter |
53 |
namespace svndigest{ |
556 |
16 Jan 08 |
peter |
54 |
|
938 |
03 Dec 09 |
peter |
55 |
void test_codon(test::Suite& suite) |
556 |
16 Jan 08 |
peter |
56 |
{ |
1152 |
07 Aug 10 |
peter |
57 |
suite.out() << "test codons" << std::endl; |
556 |
16 Jan 08 |
peter |
58 |
const Configuration& c(Configuration::instance()); |
556 |
16 Jan 08 |
peter |
59 |
if (!c.codon("foo.h")){ |
938 |
03 Dec 09 |
peter |
60 |
suite.out() << "No codon for foo.h\n"; |
938 |
03 Dec 09 |
peter |
61 |
suite.add(false); |
556 |
16 Jan 08 |
peter |
62 |
} |
1052 |
18 Apr 10 |
peter |
63 |
if (!c.codon("/dir/test.cc")){ |
938 |
03 Dec 09 |
peter |
64 |
suite.out() << "No codon for test.cc\n"; |
938 |
03 Dec 09 |
peter |
65 |
suite.add(false); |
556 |
16 Jan 08 |
peter |
66 |
} |
938 |
03 Dec 09 |
peter |
67 |
if (!c.codon("bootstrap")){ |
938 |
03 Dec 09 |
peter |
68 |
suite.out() << "No codon for bootstrap\n"; |
938 |
03 Dec 09 |
peter |
69 |
suite.add(false); |
938 |
03 Dec 09 |
peter |
70 |
} |
556 |
16 Jan 08 |
peter |
71 |
} |
556 |
16 Jan 08 |
peter |
72 |
|
1152 |
07 Aug 10 |
peter |
73 |
void test_props(test::Suite& suite) |
1152 |
07 Aug 10 |
peter |
74 |
{ |
1152 |
07 Aug 10 |
peter |
75 |
suite.out() << "test props" << std::endl; |
1152 |
07 Aug 10 |
peter |
76 |
Configuration& conf(Configuration::instance()); |
1152 |
07 Aug 10 |
peter |
77 |
std::stringstream ss; |
1373 |
10 Jun 11 |
peter |
78 |
ss << "[svn-props]\n" |
1152 |
07 Aug 10 |
peter |
79 |
<< "foo* = svndigest:ignore\n" |
1152 |
07 Aug 10 |
peter |
80 |
<< "bar* = svn:eol-style=native;svncopyright:ignore\n"; |
1152 |
07 Aug 10 |
peter |
81 |
conf.load(ss); |
1152 |
07 Aug 10 |
peter |
82 |
const std::map<std::string, std::string>& props = |
1152 |
07 Aug 10 |
peter |
83 |
conf.svn_properties("foo_bla_bla"); |
1152 |
07 Aug 10 |
peter |
84 |
if (props.find("svndigest:ignore")==props.end()) { |
1152 |
07 Aug 10 |
peter |
85 |
suite.out() << "property svndigest:ignore not set for foo_bla_bla\n"; |
1152 |
07 Aug 10 |
peter |
86 |
suite.add(false); |
1152 |
07 Aug 10 |
peter |
87 |
} |
1152 |
07 Aug 10 |
peter |
88 |
const std::map<std::string, std::string>& props2 = |
1152 |
07 Aug 10 |
peter |
89 |
conf.svn_properties("bar_bla_bla"); |
1152 |
07 Aug 10 |
peter |
90 |
std::map<std::string, std::string>::const_iterator it = |
1152 |
07 Aug 10 |
peter |
91 |
props2.find("svn:eol-style"); |
1152 |
07 Aug 10 |
peter |
92 |
if (!suite.add(it != props2.end())) |
1152 |
07 Aug 10 |
peter |
93 |
suite.out() <<"expected property 'svn:eol-style' set for bar_bla_bla\n"; |
1152 |
07 Aug 10 |
peter |
94 |
else if (!suite.add(it->second == "native")) |
1152 |
07 Aug 10 |
peter |
95 |
suite.out() << "expected 'svn:eol-style' set to 'native' " |
1152 |
07 Aug 10 |
peter |
96 |
<< "for bar_bla_bla\n"; |
1152 |
07 Aug 10 |
peter |
// checking that we return empty map for files not mentioned in config |
1152 |
07 Aug 10 |
peter |
98 |
suite.out() << "props3" << std::endl; |
1152 |
07 Aug 10 |
peter |
99 |
const std::map<std::string, std::string>& props3 = |
1152 |
07 Aug 10 |
peter |
100 |
conf.svn_properties("nothing-nothing"); |
1152 |
07 Aug 10 |
peter |
101 |
suite.add(props3.empty()); |
1152 |
07 Aug 10 |
peter |
102 |
} |
1152 |
07 Aug 10 |
peter |
103 |
|
996 |
28 Dec 09 |
peter |
104 |
void test_read_write(test::Suite& suite) |
996 |
28 Dec 09 |
peter |
105 |
{ |
996 |
28 Dec 09 |
peter |
106 |
Configuration& config = Configuration::instance(); |
996 |
28 Dec 09 |
peter |
107 |
std::stringstream ss; |
996 |
28 Dec 09 |
peter |
108 |
ss << config; |
996 |
28 Dec 09 |
peter |
109 |
config.load(ss); |
996 |
28 Dec 09 |
peter |
110 |
std::stringstream ss2; |
996 |
28 Dec 09 |
peter |
111 |
ss2 << config; |
996 |
28 Dec 09 |
peter |
112 |
if (ss2.str() != ss.str()) { |
996 |
28 Dec 09 |
peter |
113 |
suite.out() << "error: configuration output not equal\n"; |
996 |
28 Dec 09 |
peter |
114 |
suite.out() << "defalt output:\n" << ss.str() << "\n"; |
996 |
28 Dec 09 |
peter |
115 |
suite.out() << "second output:\n" << ss2.str() << "\n"; |
996 |
28 Dec 09 |
peter |
116 |
suite.add(false); |
996 |
28 Dec 09 |
peter |
117 |
} |
996 |
28 Dec 09 |
peter |
118 |
} |
996 |
28 Dec 09 |
peter |
119 |
|
556 |
16 Jan 08 |
peter |
120 |
}} // end of namespace svndigest and theplu |