diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-03-09 13:19:48 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-03-09 13:20:02 +0000 |
commit | 58daab21cd043e1dc37024a7f99b396788372918 (patch) | |
tree | 96771e43bb69f7c1c2b0b4f7374cb74d7866d0cb /web/server/h2o/libh2o/misc/oktavia/test/test-query-string-parser.jsx | |
parent | Releasing debian version 1.43.2-1. (diff) | |
download | netdata-58daab21cd043e1dc37024a7f99b396788372918.tar.xz netdata-58daab21cd043e1dc37024a7f99b396788372918.zip |
Merging upstream version 1.44.3.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | web/server/h2o/libh2o/misc/oktavia/test/test-query-string-parser.jsx | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/web/server/h2o/libh2o/misc/oktavia/test/test-query-string-parser.jsx b/web/server/h2o/libh2o/misc/oktavia/test/test-query-string-parser.jsx new file mode 100644 index 000000000..94ec7c193 --- /dev/null +++ b/web/server/h2o/libh2o/misc/oktavia/test/test-query-string-parser.jsx @@ -0,0 +1,94 @@ +import "test-case.jsx"; +import "query-string-parser.jsx"; + +class _Test extends TestCase +{ + var parser : QueryStringParser; + + override function setUp () : void + { + this.parser = new QueryStringParser(); + } + + function test_single_string_and () : void + { + this.parser.parse('word1 word2'); + this.expect(this.parser.queries.length).toBe(2); + + this.expect(this.parser.queries[0].word).toBe('word1'); + this.expect(this.parser.queries[0].or).toBe(false); + this.expect(this.parser.queries[0].not).toBe(false); + this.expect(this.parser.queries[0].raw).toBe(false); + + this.expect(this.parser.queries[1].word).toBe('word2'); + this.expect(this.parser.queries[1].or).toBe(false); + this.expect(this.parser.queries[1].not).toBe(false); + this.expect(this.parser.queries[1].raw).toBe(false); + } + + function test_single_string_or () : void + { + this.parser.parse('word1 OR word2'); + this.expect(this.parser.queries.length).toBe(2); + + this.expect(this.parser.queries[0].word).toBe('word1'); + this.expect(this.parser.queries[0].or).toBe(false); + this.expect(this.parser.queries[0].not).toBe(false); + this.expect(this.parser.queries[0].raw).toBe(false); + + this.expect(this.parser.queries[1].word).toBe('word2'); + this.expect(this.parser.queries[1].or).toBe(true); + this.expect(this.parser.queries[1].not).toBe(false); + this.expect(this.parser.queries[1].raw).toBe(false); + } + + function test_single_string_not () : void + { + this.parser.parse('word1 -word2'); + this.expect(this.parser.queries.length).toBe(2); + + this.expect(this.parser.queries[0].word).toBe('word1'); + this.expect(this.parser.queries[0].or).toBe(false); + this.expect(this.parser.queries[0].not).toBe(false); + this.expect(this.parser.queries[0].raw).toBe(false); + + this.expect(this.parser.queries[1].word).toBe('word2'); + this.expect(this.parser.queries[1].or).toBe(false); + this.expect(this.parser.queries[1].not).toBe(true); + this.expect(this.parser.queries[1].raw).toBe(false); + } + + function test_single_string_raw () : void + { + this.parser.parse('word1 "word2"'); + this.expect(this.parser.queries.length).toBe(2); + + this.expect(this.parser.queries[0].word).toBe('word1'); + this.expect(this.parser.queries[0].or).toBe(false); + this.expect(this.parser.queries[0].not).toBe(false); + this.expect(this.parser.queries[0].raw).toBe(false); + + this.expect(this.parser.queries[1].word).toBe('word2'); + this.expect(this.parser.queries[1].or).toBe(false); + this.expect(this.parser.queries[1].not).toBe(false); + this.expect(this.parser.queries[1].raw).toBe(true); + } + + function test_single_string_raw_not () : void + { + this.parser.parse('word1 -"word2"'); + this.expect(this.parser.queries.length).toBe(2); + + this.expect(this.parser.queries[0].word).toBe('word1'); + this.expect(this.parser.queries[0].or).toBe(false); + this.expect(this.parser.queries[0].not).toBe(false); + this.expect(this.parser.queries[0].raw).toBe(false); + + this.expect(this.parser.queries[1].word).toBe('word2'); + this.expect(this.parser.queries[1].or).toBe(false); + this.expect(this.parser.queries[1].not).toBe(true); + this.expect(this.parser.queries[1].raw).toBe(true); + } + +} + |