source: trunk/test/parser.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: 1.6 KB
Line 
1// $Id: parser.cc 1164 2010-08-13 20:21:40Z peter $
2
3/*
4  Copyright (C) 2006 Peter Johansson
5  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
6  Copyright (C) 2010 Peter Johansson
7
8  This file is part of svndigest, http://dev.thep.lu.se/svndigest
9
10  svndigest is free software; you can redistribute it and/or modify it
11  under the terms of the GNU General Public License as published by
12  the Free Software Foundation; either version 3 of the License, or
13  (at your option) any later version.
14
15  svndigest is distributed in the hope that it will be useful, but
16  WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18  General Public License for more details.
19
20  You should have received a copy of the GNU General Public License
21  along with svndigest. If not, see <http://www.gnu.org/licenses/>.
22*/
23
24#include "Suite.h"
25
26#include "lib/LineTypeParser.h"
27
28#include <iostream>
29#include <fstream>
30
31bool test(const std::string&, std::ostream&);
32
33
34int main(int argc, char* argv[])
35{
36  theplu::svndigest::test::Suite suite(argc, argv);
37  bool ok=true;
38  std::ofstream os("parser.tmp");
39  test("parser.cc",os);
40  test("Makefile.am",os);
41  test("../INSTALL",os);
42  return suite.exit_status();
43}
44
45bool test(const std::string& file, std::ostream& os)
46{
47  using namespace theplu::svndigest;
48  LineTypeParser parser(file);
49  std::ifstream is(file.c_str());
50  for (size_t i=0; i<parser.type().size(); ++i){
51    if (parser.type()[i]==LineTypeParser::other)
52      os << "other:   ";
53    else if (parser.type()[i]==LineTypeParser::comment)
54      os << "comment: ";
55    else
56      os << "code:    ";
57    std::string str;
58    getline(is, str);
59    os << str << "\n";
60  }
61  return true;
62}
Note: See TracBrowser for help on using the repository browser.