summaryrefslogtreecommitdiff
path: root/cli-tests/erase
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2020-04-08 14:51:57 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2020-04-27 11:38:53 +0300
commit720c5a33b6a49cf328fdd7611f49153cf8f60247 (patch)
tree9725f3d1f42ec90fde84520f49647edea013ce5e /cli-tests/erase
parent3183f3bb927a90783ae0aeaf190a0919377aabe4 (diff)
Separate tests and examples into individual packages
Also make cli module to be explicitly enabled via the config.cli configuration variable.
Diffstat (limited to 'cli-tests/erase')
-rw-r--r--cli-tests/erase/buildfile10
-rw-r--r--cli-tests/erase/driver.cxx34
-rw-r--r--cli-tests/erase/test.cli9
3 files changed, 53 insertions, 0 deletions
diff --git a/cli-tests/erase/buildfile b/cli-tests/erase/buildfile
new file mode 100644
index 0000000..024e021
--- /dev/null
+++ b/cli-tests/erase/buildfile
@@ -0,0 +1,10 @@
+# file : erase/buildfile
+# license : MIT; see accompanying LICENSE file
+
+exe{driver}: {hxx cxx}{* -test} cli.cxx{test}
+exe{driver}: test.arguments = foo -a bar -b 123 --arg -- -b 234
+
+cxx.poptions =+ "-I$out_base"
+
+cli.cxx{test}: cli{test}
+cli.options = --no-combined-flags # Can't be used with the skip unknown mode.
diff --git a/cli-tests/erase/driver.cxx b/cli-tests/erase/driver.cxx
new file mode 100644
index 0000000..af35836
--- /dev/null
+++ b/cli-tests/erase/driver.cxx
@@ -0,0 +1,34 @@
+// file : erase/driver.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// license : MIT; see accompanying LICENSE file
+
+// Test argument erasing.
+//
+
+#include <string>
+#include <cassert>
+
+#include "test.hxx"
+
+using namespace std;
+
+int
+main (int argc, char* argv[])
+{
+ options o (argc, argv, true,
+ cli::unknown_mode::skip,
+ cli::unknown_mode::skip);
+
+ assert (o.a ());
+ assert (o.b () == 123);
+
+ // We should have 'foo bar --arg -- -b 234'.
+ //
+ assert (argc == 7);
+ assert (argv[1] == string ("foo"));
+ assert (argv[2] == string ("bar"));
+ assert (argv[3] == string ("--arg"));
+ assert (argv[4] == string ("--"));
+ assert (argv[5] == string ("-b"));
+ assert (argv[6] == string ("234"));
+}
diff --git a/cli-tests/erase/test.cli b/cli-tests/erase/test.cli
new file mode 100644
index 0000000..a5d7672
--- /dev/null
+++ b/cli-tests/erase/test.cli
@@ -0,0 +1,9 @@
+// file : erase/test.cli
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// license : MIT; see accompanying LICENSE file
+
+class options
+{
+ bool -a;
+ int -b;
+};