source: trunk/test/parser.cc @ 568

Last change on this file since 568 was 556, checked in by Peter Johansson, 14 years ago

Fixing statistics bugs and links on first page

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.6 KB
Line 
1// $Id: parser.cc 556 2008-01-16 13:35:00Z peter $
2
3/*
4  Copyright (C) 2006 Peter Johansson
5  Copyright (C) 2007 Peter Johansson
6
7  This file is part of svndigest, http://trac.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 2 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 this program; if not, write to the Free Software
21  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
22  02111-1307, USA.
23*/
24
25#include "LineTypeParser.h"
26
27#include <iostream>
28#include <fstream>
29
30bool test(const std::string&, std::ostream&);
31
32int main(const int argc,const char* argv[])
33{
34  bool ok=true;
35  std::ofstream os("parser.tmp");
36  ok = ok && test("parser.cc",os);
37  ok = ok && test("Makefile.am",os);
38  ok = ok && test("../INSTALL",os);
39  return 0;
40}
41
42bool test(const std::string& file, std::ostream& os)
43{
44  using namespace theplu::svndigest;
45  LineTypeParser parser(file);
46  std::ifstream is(file.c_str());
47  for (size_t i=0; i<parser.type().size(); ++i){
48    if (parser.type()[i]==LineTypeParser::other)
49      os << "other:   ";
50    else if (parser.type()[i]==LineTypeParser::comment)
51      os << "comment: ";
52    else
53      os << "code:    ";
54    std::string str;
55    getline(is, str);
56    os << str << "\n";
57  }
58  return true;
59}
Note: See TracBrowser for help on using the repository browser.