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
  2021-12-02 10:35 ` Mergen Imeev via Tarantool-patches
  0 siblings, 1 reply; 2+ messages 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] 2+ messages in thread

* Re: [Tarantool-patches] [PATCH] sql: Update POSITION() tests
  2021-11-21 21:41 [Tarantool-patches] [PATCH] sql: Update POSITION() tests Lord via Tarantool-patches
@ 2021-12-02 10:35 ` Mergen Imeev via Tarantool-patches
  0 siblings, 0 replies; 2+ messages in thread
From: Mergen Imeev via Tarantool-patches @ 2021-12-02 10:35 UTC (permalink / raw)
  To: Lord; +Cc: tarantool-patches

Hi! Thank you for the patch! See 5 comments below.

1. Please add a hyperlink to the branch and a hyperlink to the issue when
submitting the patch. Or you can use PR. Better to use PR as your branch will
be checked out in CI.

2. Why do you need these changes? How are these changes related to the KMP?

2. Tests 1.0.1 and 1.0.3 are similar to 1.13, 1.0.5 is similar to 1.9 and 1.0.6
is similar to 1.8. Tests 1.0.2 and 1.0.4 have something new, but you can simply
add them to the end of the file. The same about changes in tests 1.63-1.65 -
you can add new tests at the end of the file instead of changing old tests.

3. Please use do_execsql_test() instead of do_test(...execsql()...).

On Mon, Nov 22, 2021 at 12:41:22AM +0300, Lord via Tarantool-patches wrote:
> 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');"
4. Please use parentheses after execsql(). Here and below.

> +test:do_execsql_test(           --TODO
5. What about this '--TODO'? Why do you need to change this test?


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-12-02 10:35 UTC | newest]

Thread overview: 2+ messages (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
2021-12-02 10:35 ` Mergen Imeev via Tarantool-patches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox