source: branches/replacing_gnuplot/test/parser_test.cc @ 866

Last change on this file since 866 was 857, checked in by Jari Häkkinen, 12 years ago

Merged trunk changes -r844:855 to replacing_gnuplot branch.

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