summaryrefslogtreecommitdiff
path: root/cli-tests/inheritance
diff options
context:
space:
mode:
Diffstat (limited to 'cli-tests/inheritance')
-rw-r--r--cli-tests/inheritance/buildfile11
-rw-r--r--cli-tests/inheritance/driver.cxx35
-rw-r--r--cli-tests/inheritance/test.cli25
-rw-r--r--cli-tests/inheritance/test.std4
4 files changed, 75 insertions, 0 deletions
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 <boris@codesynthesis.com>
+// license : MIT; see accompanying LICENSE file
+
+// Test option class inheritance.
+//
+
+#include <string>
+#include <cassert>
+#include <iostream>
+
+#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 <boris@codesynthesis.com>
+// license : MIT; see accompanying LICENSE file
+
+include <string>;
+
+class base1 = 0
+{
+ bool --very-long-flag {"Long flag."};
+};
+
+class base2
+{
+ std::string -s {"<str>", "Short string."};
+};
+
+class interm: base1
+{
+ int -i = 1 {"<num>", "Integer."};
+};
+
+class options: interm, base2
+{
+ std::string --string {"<str>", "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 <num> Integer.
+-s <str> Short string.
+--string <str> Long string.