aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/manifest-roundtrip/buildfile2
-rw-r--r--tests/manifest-roundtrip/driver.cxx52
2 files changed, 24 insertions, 30 deletions
diff --git a/tests/manifest-roundtrip/buildfile b/tests/manifest-roundtrip/buildfile
index 19678d8..7b55569 100644
--- a/tests/manifest-roundtrip/buildfile
+++ b/tests/manifest-roundtrip/buildfile
@@ -6,4 +6,4 @@ import libs = libbutl%lib{butl}
libs += $stdmod_lib
exe{driver}: {hxx cxx}{*} $libs
-exe{driver}: test.roundtrip = manifest
+exe{driver}: file{manifest}: test.roundtrip = true
diff --git a/tests/manifest-roundtrip/driver.cxx b/tests/manifest-roundtrip/driver.cxx
index 1f0b311..654763e 100644
--- a/tests/manifest-roundtrip/driver.cxx
+++ b/tests/manifest-roundtrip/driver.cxx
@@ -31,40 +31,34 @@ using namespace std;
using namespace butl;
int
-main (int argc, char* argv[])
+main ()
+try
{
- if (argc != 2)
- {
- cerr << "usage: " << argv[0] << " <file>" << endl;
- return 1;
- }
+ // Read/write in binary mode.
+ //
+ stdin_fdmode (fdstream_mode::binary);
+ stdout_fdmode (fdstream_mode::binary);
- try
- {
- ifdstream ifs (argv[1]);
- manifest_parser p (ifs, argv[1]);
+ manifest_parser p (cin, "stdin");
+ manifest_serializer s (cout, "stdout");
- stdout_fdmode (fdstream_mode::binary); // Write in binary mode.
- manifest_serializer s (cout, "stdout");
+ for (bool eom (true), eos (false); !eos; )
+ {
+ manifest_name_value nv (p.next ());
- for (bool eom (true), eos (false); !eos; )
+ if (nv.empty ()) // End pair.
{
- manifest_name_value nv (p.next ());
-
- if (nv.empty ()) // End pair.
- {
- eos = eom;
- eom = true;
- }
- else
- eom = false;
-
- s.next (nv.name, nv.value);
+ eos = eom;
+ eom = true;
}
+ else
+ eom = false;
+
+ s.next (nv.name, nv.value);
}
- catch (const exception& e)
- {
- cerr << e << endl;
- return 1;
- }
+}
+catch (const exception& e)
+{
+ cerr << e << endl;
+ return 1;
}