1 | // $Id: parser.cc 492 2007-10-14 00:35:07Z 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/trac/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 "Parser.h" |
---|
26 | |
---|
27 | #include <iostream> |
---|
28 | #include <fstream> |
---|
29 | |
---|
30 | bool test(const std::string&, std::ostream&); |
---|
31 | |
---|
32 | int 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 | |
---|
42 | bool test(const std::string& file, std::ostream& os) |
---|
43 | { |
---|
44 | using namespace theplu::svndigest; |
---|
45 | os << "Testing: " << file << std::endl; |
---|
46 | Parser parser(file); |
---|
47 | std::ifstream is(file.c_str()); |
---|
48 | for (size_t i=0; i<parser.type().size(); ++i){ |
---|
49 | if (parser.type()[i]==Parser::empty) |
---|
50 | os << "empty: "; |
---|
51 | else if (parser.type()[i]==Parser::comment) |
---|
52 | os << "comment: "; |
---|
53 | else |
---|
54 | os << "code: "; |
---|
55 | std::string str; |
---|
56 | getline(is, str); |
---|
57 | os << str << "\n"; |
---|
58 | } |
---|
59 | return true; |
---|
60 | } |
---|