summaryrefslogtreecommitdiff
path: root/tests/parser/driver.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2009-08-22 10:25:12 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2009-08-22 10:25:12 +0200
commitfabbe60b014a02b2ab94e57ab3866e28c67d36ce (patch)
tree4d776980683dcc118392bd7b67520383918be8ab /tests/parser/driver.cxx
parent1470fed809be7b11f147f8a6ca924a252b473c97 (diff)
Add a test for the parser
Diffstat (limited to 'tests/parser/driver.cxx')
-rw-r--r--tests/parser/driver.cxx34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/parser/driver.cxx b/tests/parser/driver.cxx
new file mode 100644
index 0000000..c783503
--- /dev/null
+++ b/tests/parser/driver.cxx
@@ -0,0 +1,34 @@
+// file : tests/parser/driver.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2009 Code Synthesis Tools CC
+// license : MIT; see accompanying LICENSE file
+
+#include <fstream>
+#include <iostream>
+
+#include <cli/parser.hxx>
+
+using namespace std;
+
+int main (int argc, char* argv[])
+{
+ if (argc != 2)
+ {
+ cerr << "usage: " << argv[0] << " file.cli" << endl;
+ return 1;
+ }
+
+ try
+ {
+ ifstream ifs;
+ ifs.exceptions (ifstream::failbit | ifstream::badbit);
+ ifs.open (argv[1]);
+
+ Parser parser;
+ parser.parse (ifs, argv[1]);
+ }
+ catch (Parser::InvalidInput const&)
+ {
+ return 1;
+ }
+}