Tarantool development patches archive
 help / color / mirror / Atom feed
From: Lord via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: tarantool-patches@dev.tarantool.org
Cc: Gleb <kashkin.nsaa@gmail.com>
Subject: [Tarantool-patches] [PATCH] sql: Update POSITION() tests
Date: Mon, 22 Nov 2021 00:41:22 +0300	[thread overview]
Message-ID: <20211121214122.103443-1-lord.nemo@protonmail.com> (raw)

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

             reply	other threads:[~2021-11-21 21:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-21 21:41 Lord via Tarantool-patches [this message]
2021-12-02 10:35 ` Mergen Imeev via Tarantool-patches

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211121214122.103443-1-lord.nemo@protonmail.com \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=kashkin.nsaa@gmail.com \
    --subject='Re: [Tarantool-patches] [PATCH] sql: Update POSITION() tests' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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