aboutsummaryrefslogtreecommitdiff
path: root/tests/manifest/driver.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'tests/manifest/driver.cxx')
-rw-r--r--tests/manifest/driver.cxx46
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/manifest/driver.cxx b/tests/manifest/driver.cxx
new file mode 100644
index 0000000..ff6005c
--- /dev/null
+++ b/tests/manifest/driver.cxx
@@ -0,0 +1,46 @@
+// file : tests/manifest/driver.cxx -*- C++ -*-
+// copyright : Copyright (c) 2014-2015 Code Synthesis Ltd
+// license : MIT; see accompanying LICENSE file
+
+#include <fstream>
+#include <iostream>
+
+#include <bpkg/manifest>
+#include <bpkg/manifest-parser>
+#include <bpkg/manifest-serializer>
+
+using namespace std;
+using namespace bpkg;
+
+int
+main (int argc, char* argv[])
+{
+ if (argc != 2)
+ {
+ cerr << "usage: " << argv[0] << " <file>" << endl;
+ return 1;
+ }
+
+ try
+ {
+ ifstream ifs;
+ ifs.exceptions (ifstream::badbit | ifstream::failbit);
+ ifs.open (argv[1], ifstream::in | ifstream::binary);
+
+ manifest_parser p (ifs, argv[1]);
+ manifests ms (p);
+
+ manifest_serializer s (cout, "stdout");
+ ms.serialize (s);
+ }
+ catch (const ios_base::failure&)
+ {
+ cerr << "io failure" << endl;
+ return 1;
+ }
+ catch (const std::exception& e)
+ {
+ cerr << e.what () << endl;
+ return 1;
+ }
+}