From 58daab21cd043e1dc37024a7f99b396788372918 Mon Sep 17 00:00:00 2001
From: Daniel Baumann <daniel.baumann@progress-linux.org>
Date: Sat, 9 Mar 2024 14:19:48 +0100
Subject: Merging upstream version 1.44.3.

Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
---
 .../misc/oktavia/test/test-query-string-parser.jsx | 94 ++++++++++++++++++++++
 1 file changed, 94 insertions(+)
 create mode 100644 web/server/h2o/libh2o/misc/oktavia/test/test-query-string-parser.jsx

(limited to 'web/server/h2o/libh2o/misc/oktavia/test/test-query-string-parser.jsx')

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);
+    }
+
+}
+
-- 
cgit v1.2.3

