source: trunk/test/config.cc @ 1164

Last change on this file since 1164 was 1164, checked in by Peter Johansson, 11 years ago

improve lazycheck dependencies

To allow editing dependencies, the tests must have a suffix mentioned
in TEST_EXTENSION and it seems smoother if this suffix starts with a
period (.). Therefore tests are now named foo.test (rather than
foo_test before) and corresponding source is named foo.cc (rather than
foo_test.cc before). The change is documented in section 'Writing C++
tests' in test/README.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.4 KB
Line 
1// $Id: config.cc 1164 2010-08-13 20:21:40Z 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
27namespace theplu{
28namespace svndigest{
29  void test_codon(test::Suite&);
30  void test_read_write(test::Suite&);
31  void test_props(test::Suite&);
32}} // end of namespace svndigest and theplu
33
34
35int main( int argc, char* argv[])
36{
37  using namespace theplu::svndigest;
38  test::Suite suite(argc, argv, false);
39
40  test_codon(suite);
41  test_read_write(suite);
42  test_props(suite);
43                                                                               
44  return suite.exit_status();
45}
46
47
48namespace theplu{
49namespace svndigest{
50
51  void test_codon(test::Suite& suite)
52  {
53    suite.out() << "test codons" << std::endl;
54    const Configuration& c(Configuration::instance());
55    if (!c.codon("foo.h")){
56      suite.out() << "No codon for foo.h\n";
57      suite.add(false);
58    }
59    if (!c.codon("/dir/test.cc")){
60      suite.out() << "No codon for test.cc\n";
61      suite.add(false);
62    }
63    if (!c.codon("bootstrap")){
64      suite.out() << "No codon for bootstrap\n";
65      suite.add(false);
66    }
67  }
68 
69  void test_props(test::Suite& suite)
70  {
71    suite.out() << "test props" << std::endl;
72    Configuration& conf(Configuration::instance());
73    std::stringstream ss;
74    ss << "[svn_props]\n"
75       << "foo* = svndigest:ignore\n"
76       << "bar* = svn:eol-style=native;svncopyright:ignore\n";
77    conf.load(ss);
78    const std::map<std::string, std::string>& props =
79      conf.svn_properties("foo_bla_bla");
80    if (props.find("svndigest:ignore")==props.end()) {
81        suite.out() << "property svndigest:ignore not set for foo_bla_bla\n";
82        suite.add(false);
83    }
84    const std::map<std::string, std::string>& props2 =
85      conf.svn_properties("bar_bla_bla");
86    std::map<std::string, std::string>::const_iterator it =
87      props2.find("svn:eol-style");
88    if (!suite.add(it != props2.end()))
89      suite.out() <<"expected property 'svn:eol-style' set for bar_bla_bla\n";
90    else if (!suite.add(it->second == "native"))
91      suite.out() << "expected 'svn:eol-style' set to 'native' "
92                  << "for bar_bla_bla\n";
93    // checking that we return empty map for files not mentioned in config
94    suite.out() << "props3" << std::endl;
95    const std::map<std::string, std::string>& props3 =
96      conf.svn_properties("nothing-nothing");
97    suite.add(props3.empty());
98  }
99
100  void test_read_write(test::Suite& suite)
101  {
102    Configuration& config = Configuration::instance();
103    std::stringstream ss;
104    ss << config;
105    config.load(ss);
106    std::stringstream ss2;
107    ss2 << config;
108    if (ss2.str() != ss.str()) {
109      suite.out() << "error: configuration output not equal\n";
110      suite.out() << "defalt output:\n" << ss.str() << "\n";
111      suite.out() << "second output:\n" << ss2.str() << "\n";
112      suite.add(false);
113    }
114  }
115
116}} // end of namespace svndigest and theplu
Note: See TracBrowser for help on using the repository browser.