summaryrefslogtreecommitdiffstats
path: root/web/server/h2o/libh2o/misc/oktavia/test/test-getopt.jsx
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 02:57:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 02:57:58 +0000
commitbe1c7e50e1e8809ea56f2c9d472eccd8ffd73a97 (patch)
tree9754ff1ca740f6346cf8483ec915d4054bc5da2d /web/server/h2o/libh2o/misc/oktavia/test/test-getopt.jsx
parentInitial commit. (diff)
downloadnetdata-upstream.tar.xz
netdata-upstream.zip
Adding upstream version 1.44.3.upstream/1.44.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'web/server/h2o/libh2o/misc/oktavia/test/test-getopt.jsx')
-rw-r--r--web/server/h2o/libh2o/misc/oktavia/test/test-getopt.jsx84
1 files changed, 84 insertions, 0 deletions
diff --git a/web/server/h2o/libh2o/misc/oktavia/test/test-getopt.jsx b/web/server/h2o/libh2o/misc/oktavia/test/test-getopt.jsx
new file mode 100644
index 00000000..63731b92
--- /dev/null
+++ b/web/server/h2o/libh2o/misc/oktavia/test/test-getopt.jsx
@@ -0,0 +1,84 @@
+import "test-case.jsx";
+import "getopt.jsx";
+
+class _Test extends TestCase
+{
+ function test_empty () : void
+ {
+ var parser = new BasicParser('', [] : string[]);
+ this.expect(parser.getopt()).toBe(null);
+ }
+
+ function test_silent () : void
+ {
+ var parser = new BasicParser(':', [] : string[]);
+ this.expect(parser.getopt()).toBe(null);
+ }
+
+ function test_args_without_param_01 () : void
+ {
+ var parser = new BasicParser(':l', [] : string[]);
+ this.expect(parser.getopt()).toBe(null);
+ }
+
+ function test_args_without_param_02 () : void
+ {
+ var parser = new BasicParser(':l:', [] : string[]);
+ this.expect(parser.getopt()).toBe(null);
+ }
+
+ function test_args_without_param_03 () : void
+ {
+ var parser = new BasicParser(':las', [] : string[]);
+ this.expect(parser.getopt()).toBe(null);
+ }
+
+ function test_args_without_param_04 () : void
+ {
+ var parser = new BasicParser(':l:a:s:', [] : string[]);
+ this.expect(parser.getopt()).toBe(null);
+ }
+
+ function test_long_args_without_param () : void
+ {
+ var parser = new BasicParser(':l:(long)', [] : string[]);
+ this.expect(parser.getopt()).toBe(null);
+ }
+
+ function test_args () : void
+ {
+ var parser = new BasicParser(':l:(long)', ['-l', 'arg1', '--long=q', 'b', '--long', 'foo']);
+ var opt = parser.getopt();
+ this.expect(opt.option).toBe('l');
+ this.expect(opt.optarg).toBe('arg1');
+ opt = parser.getopt();
+ this.expect(opt.option).toBe('l');
+ this.expect(opt.optarg).toBe('q');
+ opt = parser.getopt();
+ this.expect(opt.option).toBe('b');
+ opt = parser.getopt();
+ this.expect(opt.option).toBe('--long');
+ opt = parser.getopt();
+ this.expect(opt.option).toBe('foo');
+ }
+
+ function test_aliased_long_args_without_param_01 () : void
+ {
+ var parser = new BasicParser(':l:(long)(longer)', [] : string[]);
+ this.expect(parser.getopt()).toBe(null);
+ }
+
+ function test_aliased_long_args_without_param_02 () : void
+ {
+ var parser = new BasicParser(':la:r(recurse)(recur)f:(file)(filename)q', [] : string[]);
+ this.expect(parser.getopt()).toBe(null);
+ }
+
+ function test_extra_options () : void
+ {
+ var parser = new BasicParser('la:r(recurse)(recur)f:(file)(filename)q', ['extra1', 'extra2']);
+ this.expect(parser.getopt().option).toBe('extra1');
+ this.expect(parser.getopt().option).toBe('extra2');
+ this.expect(parser.getopt()).toBe(null);
+ }
+}