1 | // $Id: config_test.cc 1119 2010-07-04 18:34:07Z peter $ |
---|
2 | |
---|
3 | /* |
---|
4 | Copyright (C) 2008 Jari Häkkinen, Peter Johansson |
---|
5 | Copyright (C) 2009, 2010 Peter Johansson |
---|
6 | |
---|
7 | This file is part of svndigest, http://dev.thep.lu.se/svndigest |
---|
8 | |
---|
9 | svndigest is free software; you can redistribute it and/or modify it |
---|
10 | under the terms of the GNU General Public License as published by |
---|
11 | the Free Software Foundation; either version 3 of the License, or |
---|
12 | (at your option) any later version. |
---|
13 | |
---|
14 | svndigest is distributed in the hope that it will be useful, but |
---|
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
17 | General Public License for more details. |
---|
18 | |
---|
19 | You should have received a copy of the GNU General Public License |
---|
20 | along with svndigest. If not, see <http://www.gnu.org/licenses/>. |
---|
21 | */ |
---|
22 | |
---|
23 | #include "Suite.h" |
---|
24 | |
---|
25 | #include "lib/Configuration.h" |
---|
26 | |
---|
27 | namespace theplu{ |
---|
28 | namespace svndigest{ |
---|
29 | void test_codon(test::Suite&); |
---|
30 | void test_read_write(test::Suite&); |
---|
31 | }} // end of namespace svndigest and theplu |
---|
32 | |
---|
33 | |
---|
34 | int main( int argc, char* argv[]) |
---|
35 | { |
---|
36 | using namespace theplu::svndigest; |
---|
37 | test::Suite suite(argc, argv, false); |
---|
38 | |
---|
39 | test_codon(suite); |
---|
40 | test_read_write(suite); |
---|
41 | |
---|
42 | if (suite.ok()) { |
---|
43 | suite.out() << "Test is Ok!" << std::endl; |
---|
44 | return 0; |
---|
45 | } |
---|
46 | suite.out() << "Test failed." << std::endl; |
---|
47 | return 1; |
---|
48 | } |
---|
49 | |
---|
50 | |
---|
51 | namespace theplu{ |
---|
52 | namespace svndigest{ |
---|
53 | |
---|
54 | void test_codon(test::Suite& suite) |
---|
55 | { |
---|
56 | const Configuration& c(Configuration::instance()); |
---|
57 | if (!c.codon("foo.h")){ |
---|
58 | suite.out() << "No codon for foo.h\n"; |
---|
59 | suite.add(false); |
---|
60 | } |
---|
61 | if (!c.codon("/dir/test.cc")){ |
---|
62 | suite.out() << "No codon for test.cc\n"; |
---|
63 | suite.add(false); |
---|
64 | } |
---|
65 | if (!c.codon("bootstrap")){ |
---|
66 | suite.out() << "No codon for bootstrap\n"; |
---|
67 | suite.add(false); |
---|
68 | } |
---|
69 | } |
---|
70 | |
---|
71 | void test_read_write(test::Suite& suite) |
---|
72 | { |
---|
73 | Configuration& config = Configuration::instance(); |
---|
74 | std::stringstream ss; |
---|
75 | ss << config; |
---|
76 | config.load(ss); |
---|
77 | std::stringstream ss2; |
---|
78 | ss2 << config; |
---|
79 | if (ss2.str() != ss.str()) { |
---|
80 | suite.out() << "error: configuration output not equal\n"; |
---|
81 | suite.out() << "defalt output:\n" << ss.str() << "\n"; |
---|
82 | suite.out() << "second output:\n" << ss2.str() << "\n"; |
---|
83 | suite.add(false); |
---|
84 | } |
---|
85 | } |
---|
86 | |
---|
87 | }} // end of namespace svndigest and theplu |
---|