Tarantool development patches archive
 help / color / mirror / Atom feed
* [Tarantool-patches] [PATCH] sql: Update POSITION() tests
@ 2021-11-21 21:41 Lord via Tarantool-patches
  0 siblings, 0 replies; only message in thread
From: Lord via Tarantool-patches @ 2021-11-21 21:41 UTC (permalink / raw)
  To: tarantool-patches; +Cc: Gleb

From: Gleb <kashkin.nsaa@gmail.com>

Updates positioning tests to correspond with KMP introduction
patch. Removes unicode_ci-based tests and adds more tests
on general correctness.

Needed for tarantool/tarantool#6492
---
 test/sql-tap/position.test.lua | 94 +++++++++++++++++++++++++---------
 1 file changed, 71 insertions(+), 23 deletions(-)

diff --git a/test/sql-tap/position.test.lua b/test/sql-tap/position.test.lua
index 6a96ed9bc..d35f00122 100755
--- a/test/sql-tap/position.test.lua
+++ b/test/sql-tap/position.test.lua
@@ -1,6 +1,66 @@
 #!/usr/bin/env tarantool
 local test = require("sqltester")
-test:plan(80)
+test:plan(86)
+
+test:do_test(
+    "position-1.0.1",
+    function()
+        return test:execsql "SELECT position('ststs', 'statemenstrststs');"
+    end, {
+        -- <position-1.0.1>
+        12
+        -- </position-1.0.1>
+    })
+
+test:do_test(
+    "position-1.0.2",
+    function()
+        return test:execsql "SELECT position('abc', 'abdcdefgabcabcabc');"
+    end, {
+        -- <position-1.0.2>
+        9
+        -- </position-1.0.2>
+    })
+
+test:do_test(
+    "position-1.0.3",
+    function()
+        return test:execsql "SELECT position('aaabab', 'aabaaabab');"
+    end, {
+        -- <position-1.0.3>
+        4
+        -- </position-1.0.3>
+    })
+
+test:do_test(
+    "position-1.0.4",
+    function()
+        return test:execsql "SELECT position('abcABCabc', 'abcABCDabcABCabc');"
+    end, {
+        -- <position-1.0.4>
+        8
+        -- </position-1.0.4>
+    })
+
+test:do_test(
+    "position-1.0.5",
+    function()
+        return test:execsql "SELECT position('abc', 'abc');"
+    end, {
+        -- <position-1.0.5>
+        1
+        -- </position-1.0.5>
+    })
+
+test:do_test(
+    "position-1.0.6",
+    function()
+        return test:execsql "SELECT position('a', 'bcdefg');"
+    end, {
+        -- <position-1.0.6>
+        0
+        -- </position-1.0.6>
+    })
 
 test:do_test(
     "position-1.1",
@@ -671,45 +731,43 @@ test:do_execsql_test(
         -- </position-1.62>
     })
 
--- Tests that make use of collations.
--- A short remainder of how "unicode" and "unicode_ci" collations
--- works:
--- unicode_ci: „a“ = „A“ = „á“ = „Á“.
--- unicode: all symbols above are pairwise unequal.
-
--- Collation is set in space format.
+-- Basic logic tests
 
-test:do_execsql_test(
+test:do_execsql_test(           --TODO
     "position-1.63",
     [[
-        CREATE TABLE test1 (s1 VARCHAR(5) PRIMARY KEY COLLATE "unicode_ci");
-        INSERT INTO test1 VALUES('à');
-        SELECT POSITION('a', s1) FROM test1;
-        DELETE FROM test1;
+        SELECT position('qwerqwer', 'qwertqwertyqwerqwerty')
     ]], {
-        1
+        -- <position-1.63>
+        12
+        -- </position-1.63>
     }
 )
 
 test:do_execsql_test(
     "position-1.64",
     [[
-        INSERT INTO test1 VALUES('qwèrty');
-        SELECT POSITION('er', s1) FROM test1;
+        CREATE TABLE test1 (s1 VARCHAR(5) PRIMARY KEY COLLATE "unicode_ci");
+        INSERT INTO test1 VALUES('qwèrtyqwertyqwerty');
+        SELECT POSITION('qwertyqwerty', s1) FROM test1;
         DELETE FROM test1;
     ]], {
-        3
+        -- <position-1.64>
+        7
+        -- </position-1.64>
     }
 )
 
 test:do_execsql_test(
     "position-1.65",
     [[
-        INSERT INTO test1 VALUES('qwèrtÿ');
-        SELECT POSITION('y', s1) FROM test1;
+        INSERT INTO test1 VALUES('qwèrtÿqwerty');
+        SELECT POSITION('tÿqwer', s1) FROM test1;
         DELETE FROM test1;
     ]], {
-        6
+        -- <position-1.65>
+        5
+        -- </position-1.65>
     }
 )
 
-- 
2.33.1

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-11-21 21:41 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-21 21:41 [Tarantool-patches] [PATCH] sql: Update POSITION() tests Lord via Tarantool-patches

Tarantool development patches archive

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://lists.tarantool.org/tarantool-patches/0 tarantool-patches/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 tarantool-patches tarantool-patches/ https://lists.tarantool.org/tarantool-patches \
		tarantool-patches@dev.tarantool.org.
	public-inbox-index tarantool-patches

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git