aboutsummaryrefslogtreecommitdiff
path: root/tests/sendmail/driver.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'tests/sendmail/driver.cxx')
-rw-r--r--tests/sendmail/driver.cxx42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/sendmail/driver.cxx b/tests/sendmail/driver.cxx
new file mode 100644
index 0000000..9e1af96
--- /dev/null
+++ b/tests/sendmail/driver.cxx
@@ -0,0 +1,42 @@
+// file : tests/sendmail/driver.cxx -*- C++ -*-
+// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
+// license : MIT; see accompanying LICENSE file
+
+#include <iostream>
+#include <system_error>
+
+#include <butl/path>
+#include <butl/utility> // operator<<(ostream, exception)
+#include <butl/sendmail>
+
+using namespace std;
+using namespace butl;
+
+// Usage: argv[0] <to>
+//
+int
+main (int argc, const char* argv[])
+try
+{
+ assert (argc == 2);
+
+ sendmail sm ([] (const char* c[], std::size_t n)
+ {
+ process::print (cerr, c, n); cerr << endl;
+ },
+ 2,
+ "",
+ "tests/sendmail/driver",
+ {argv[1]});
+
+ sm.out << cin.rdbuf ();
+ sm.out.close ();
+
+ if (!sm.wait ())
+ return 1; // Assume diagnostics has been issued.
+}
+catch (const system_error& e)
+{
+ cerr << argv[0] << ": " << e << endl;
+ return 1;
+}