[217] | 1 | // $Id: parser.cc 218 2006-10-01 08:17:47Z peter $ |
---|
| 2 | |
---|
| 3 | /* |
---|
| 4 | Copyright (C) 2006 Peter Johansson |
---|
| 5 | |
---|
| 6 | This file is part of svndigest, http://lev.thep.lu.se/trac/svndigest |
---|
| 7 | |
---|
| 8 | svndigest is free software; you can redistribute it and/or modify it |
---|
| 9 | under the terms of the GNU General Public License as published by |
---|
| 10 | the Free Software Foundation; either version 2 of the License, or |
---|
| 11 | (at your option) any later version. |
---|
| 12 | |
---|
| 13 | svndigest is distributed in the hope that it will be useful, but |
---|
| 14 | WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
| 16 | General Public License for more details. |
---|
| 17 | |
---|
| 18 | You should have received a copy of the GNU General Public License |
---|
| 19 | along with this program; if not, write to the Free Software |
---|
| 20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
---|
| 21 | 02111-1307, USA. |
---|
| 22 | */ |
---|
| 23 | |
---|
| 24 | #include "Parser.h" |
---|
| 25 | |
---|
| 26 | #include <iostream> |
---|
| 27 | #include <fstream> |
---|
| 28 | |
---|
| 29 | bool test(const std::string&, std::ostream&); |
---|
| 30 | |
---|
| 31 | int 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); |
---|
[218] | 37 | ok = ok && test("../INSTALL",os); |
---|
[217] | 38 | return 0; |
---|
| 39 | } |
---|
| 40 | |
---|
| 41 | bool test(const std::string& file, std::ostream& os) |
---|
| 42 | { |
---|
| 43 | using namespace theplu::svndigest; |
---|
| 44 | os << "Testing: " << file << std::endl; |
---|
| 45 | Parser 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]==Parser::empty) |
---|
| 49 | os << "empty: "; |
---|
| 50 | else if (parser.type()[i]==Parser::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 | } |
---|