source: trunk/test/parser.cc

Last change on this file was 1418, checked in by Peter Johansson, 10 years ago

avoid warnings (-Wall)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 1.6 KB
RevLine 
[217]1// $Id: parser.cc 1418 2011-10-25 01:00:49Z peter $
2
3/*
4  Copyright (C) 2006 Peter Johansson
[978]5  Copyright (C) 2007, 2008 Jari Häkkinen, Peter Johansson
[1127]6  Copyright (C) 2010 Peter Johansson
[217]7
[687]8  This file is part of svndigest, http://dev.thep.lu.se/svndigest
[217]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
[693]12  the Free Software Foundation; either version 3 of the License, or
[217]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
[693]21  along with svndigest. If not, see <http://www.gnu.org/licenses/>.
[217]22*/
23
[1162]24#include "Suite.h"
25
[1119]26#include "lib/LineTypeParser.h"
[217]27
28#include <iostream>
29#include <fstream>
30
31bool test(const std::string&, std::ostream&);
32
[1162]33
34int main(int argc, char* argv[])
[217]35{
[1162]36  theplu::svndigest::test::Suite suite(argc, argv);
[217]37  std::ofstream os("parser.tmp");
[1163]38  test("parser.cc",os);
39  test("Makefile.am",os);
40  test("../INSTALL",os);
[1162]41  return suite.exit_status();
[217]42}
43
44bool test(const std::string& file, std::ostream& os)
45{
46  using namespace theplu::svndigest;
[552]47  LineTypeParser parser(file);
[217]48  std::ifstream is(file.c_str());
49  for (size_t i=0; i<parser.type().size(); ++i){
[552]50    if (parser.type()[i]==LineTypeParser::other)
[528]51      os << "other:   ";
[552]52    else if (parser.type()[i]==LineTypeParser::comment)
[217]53      os << "comment: ";
54    else
55      os << "code:    ";
56    std::string str;
57    getline(is, str);
58    os << str << "\n";
59  }
60  return true;
61}
Note: See TracBrowser for help on using the repository browser.