From 720c5a33b6a49cf328fdd7611f49153cf8f60247 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 8 Apr 2020 14:51:57 +0300 Subject: Separate tests and examples into individual packages Also make cli module to be explicitly enabled via the config.cli configuration variable. --- cli-tests/erase/buildfile | 10 ++++++++++ cli-tests/erase/driver.cxx | 34 ++++++++++++++++++++++++++++++++++ cli-tests/erase/test.cli | 9 +++++++++ 3 files changed, 53 insertions(+) create mode 100644 cli-tests/erase/buildfile create mode 100644 cli-tests/erase/driver.cxx create mode 100644 cli-tests/erase/test.cli (limited to 'cli-tests/erase') 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 +// license : MIT; see accompanying LICENSE file + +// Test argument erasing. +// + +#include +#include + +#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 +// license : MIT; see accompanying LICENSE file + +class options +{ + bool -a; + int -b; +}; -- cgit v1.1