diff options
Diffstat (limited to 'staging/adblock/test/parser.cpp')
-rw-r--r-- | staging/adblock/test/parser.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/staging/adblock/test/parser.cpp b/staging/adblock/test/parser.cpp new file mode 100644 index 0000000..0ce1121 --- /dev/null +++ b/staging/adblock/test/parser.cpp @@ -0,0 +1,32 @@ +#include "filterlist.h" +#include <QFile> +#include <QTextStream> + +int main(int argc, char **argv) +{ + if(argc < 2) { + qDebug("usage: %s list1.txt ...", argv[0]); + return 77; + } + + for(int i = 1; i < argc; ++i) { + QFile f(argv[i]); + if(!f.open(QIODevice::ReadOnly | QIODevice::Text)) { + qDebug("could not open %s", argv[i]); + return -1; + } + + AdblockPlus::FilterList list; + QTextStream stream(&f); + const auto result = list.parse(stream); + qDebug("[%s]: %s", argv[i], (result.state == AdblockPlus::FilterList::Ok) ? "okay" : "failed"); + qDebug(" total: %i", result.lines_total); + qDebug("comments: %i", result.lines_comments); + qDebug(" ignored: %i", result.lines_ignored); + qDebug(" parsed: %i", result.lines_parsed); + qDebug(" failed: %i", result.lines_failed); + + f.close(); + } + return 0; +} |