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/inheritance/buildfile | 11 +++++++++++ cli-tests/inheritance/driver.cxx | 35 +++++++++++++++++++++++++++++++++++ cli-tests/inheritance/test.cli | 25 +++++++++++++++++++++++++ cli-tests/inheritance/test.std | 4 ++++ 4 files changed, 75 insertions(+) create mode 100644 cli-tests/inheritance/buildfile create mode 100644 cli-tests/inheritance/driver.cxx create mode 100644 cli-tests/inheritance/test.cli create mode 100644 cli-tests/inheritance/test.std (limited to 'cli-tests/inheritance') diff --git a/cli-tests/inheritance/buildfile b/cli-tests/inheritance/buildfile new file mode 100644 index 0000000..6fe1ecc --- /dev/null +++ b/cli-tests/inheritance/buildfile @@ -0,0 +1,11 @@ +# file : inheritance/buildfile +# license : MIT; see accompanying LICENSE file + +exe{driver}: {hxx cxx}{* -test} cli.cxx{test} +exe{driver}: file{test.std}: test.stdout = true +exe{driver}: test.arguments = --very-long-flag -s short -i 123 --string long + +cxx.poptions =+ "-I$out_base" + +cli.cxx{test}: cli{test} +cli.options = --generate-description --option-length 17 diff --git a/cli-tests/inheritance/driver.cxx b/cli-tests/inheritance/driver.cxx new file mode 100644 index 0000000..4acab0d --- /dev/null +++ b/cli-tests/inheritance/driver.cxx @@ -0,0 +1,35 @@ +// file : inheritance/driver.cxx +// author : Boris Kolpackov +// license : MIT; see accompanying LICENSE file + +// Test option class inheritance. +// + +#include +#include +#include + +#include "test.hxx" + +using namespace std; + +int +main (int argc, char* argv[]) +{ + const cli::options& d (options::description ()); + + assert (d.size () == 4); + assert (d[0].name () == "--very-long-flag"); + assert (d[1].name () == "-i"); + assert (d[2].name () == "-s"); + assert (d[3].name () == "--string"); + + options o (argc, argv); + + assert (o.very_long_flag ()); + assert (o.s () == "short"); + assert (o.i () == 123); + assert (o.string () == "long"); + + options::print_usage (cout); +} diff --git a/cli-tests/inheritance/test.cli b/cli-tests/inheritance/test.cli new file mode 100644 index 0000000..3b73848 --- /dev/null +++ b/cli-tests/inheritance/test.cli @@ -0,0 +1,25 @@ +// file : inheritance/test.cli +// author : Boris Kolpackov +// license : MIT; see accompanying LICENSE file + +include ; + +class base1 = 0 +{ + bool --very-long-flag {"Long flag."}; +}; + +class base2 +{ + std::string -s {"", "Short string."}; +}; + +class interm: base1 +{ + int -i = 1 {"", "Integer."}; +}; + +class options: interm, base2 +{ + std::string --string {"", "Long string."}; +}; diff --git a/cli-tests/inheritance/test.std b/cli-tests/inheritance/test.std new file mode 100644 index 0000000..4c93225 --- /dev/null +++ b/cli-tests/inheritance/test.std @@ -0,0 +1,4 @@ +--very-long-flag Long flag. +-i Integer. +-s Short string. +--string Long string. -- cgit v1.1