Skip to content

Commit

Permalink
sql: Convert 16 tests; add new test type; fix regexp result matching
Browse files Browse the repository at this point in the history
sqltester:
  - Fix bug in regexp result matcher (last symbol was cut from regexp pattern)
  - Add new test type "do_select_tests"
  - Add procedure "drop_all_tables"

Fixing bug in regexp result matching pointed to wrong success
results in whereF test. These tests are commented by now.

Part of #2381
  • Loading branch information
Khatskevich authored and Kirill Yukhin committed Jun 9, 2017
1 parent ca70128 commit 47b70d9
Show file tree
Hide file tree
Showing 18 changed files with 9,349 additions and 6 deletions.
57 changes: 57 additions & 0 deletions test/sql-tap/atof1.test.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/usr/bin/env tarantool
test = require("sqltester")
test:plan(9999)

--!./tcltestrunner.lua
-- 2012 June 18
--
-- The author disclaims copyright to this source code. In place of
-- a legal notice, here is a blessing:
--
-- May you do good and not evil.
-- May you find forgiveness for yourself and forgive others.
-- May you share freely, never taking more than you give.
--
-------------------------------------------------------------------------
--
-- Tests of the sqlite3AtoF() function.
--
-- ["set","testdir",[["file","dirname",["argv0"]]]]
-- ["source",[["testdir"],"\/tester.tcl"]]


for i = 1, 10000 - 1, 1 do
local pow = math.random(100)
local x = math.pow((math.random()-0.5)*2*math.random(), pow)

-- Pointless test
-- local xf = string.format("%.32e", x)
-- print("\nxf "..xf.." x "..x)
-- -- Verify that text->real conversions get exactly same ieee754 floating-
-- -- point value in SQLite as they do in TCL.
-- --
-- test:do_test(
-- "atof1-1."..i..".1",
-- function()
-- local y = test:execsql("SELECT "..xf.."="..x)
-- return y
-- end, {
-- 1
-- })

-- Verify that round-trip real->text->real conversions using the quote()
-- function preserve the bits of the numeric value exactly.
--
test:do_test(
"atof1-1."..i..".2",
function()
local y = test:execsql(string.format("SELECT %s=CAST(quote(%s) AS real)",x, x))
return y
end, {
1
})

end


test:finish_test()
Loading

0 comments on commit 47b70d9

Please sign in to comment.