source: trunk/test/parser_test.cc @ 1127

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

updating copyright statements

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.6 KB
Line 
1// $Id: parser_test.cc 1127 2010-07-15 22:01:38Z 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 "lib/LineTypeParser.h"
25
26#include <iostream>
27#include <fstream>
28
29bool test(const std::string&, std::ostream&);
30
31int main(const int argc,const char* argv[])
32{
33  bool ok=true;
34  std::ofstream os("parser.tmp");
35  ok = ok && test("parser.cc",os);
36  ok = ok && test("Makefile.am",os);
37  ok = ok && test("../INSTALL",os);
38  return 0;
39}
40
41bool test(const std::string& file, std::ostream& os)
42{
43  using namespace theplu::svndigest;
44  LineTypeParser parser(file);
45  std::ifstream is(file.c_str());
46  for (size_t i=0; i<parser.type().size(); ++i){
47    if (parser.type()[i]==LineTypeParser::other)
48      os << "other:   ";
49    else if (parser.type()[i]==LineTypeParser::comment)
50      os << "comment: ";
51    else
52      os << "code:    ";
53    std::string str;
54    getline(is, str);
55    os << str << "\n";
56  }
57  return true;
58}
Note: See TracBrowser for help on using the repository browser.