LuaSQLite3

Check-in [697ae4953a]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add test case for ticket [d54dc056330c] -- cannot reproduce.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | trunk
Files: files | file ages | folders
SHA1: 697ae4953a4590158ec2a4f2aace92f3cd077549
User & Date: e 2018-06-30 19:29:41
Original Comment: Add test case for tiket [d54dc056330c] -- cannot reproduce.
References
2018-06-30
19:31 Closed ticket [d54dc05633]: INSERTING a blob (wav-file) can get it back the same... plus 4 other changes artifact: ec0e76cca0 user: e
Context
2018-06-30
19:29
Add test case for ticket [d54dc056330c] -- cannot reproduce. Leaf check-in: 697ae4953a user: e tags: trunk
17:35
Update HISTORY, remove obsolete file. check-in: dd7e65e22e user: e tags: fsl_9y, trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to test/tests-sqlite3.lua.

22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
....
1239
1240
1241
1242
1243
1244
1245
1246



















































1247
1248
    IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
    CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
    TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
    SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

--]]--------------------------------------------------------------------------

-- extended for LuaSQLite3, and for Lua 5.2 (using lunitx)
-- Copyright (c) 2005-13 Doug Currie
-- Same license as above

local sqlite3 = require(arg[1]) -- "lsqlite3complete" or "lsqlite3"

local os = os

--local lunit = require "lunitx"
................................................................................
  for a, b in db2:urows("SELECT * FROM test1 ORDER BY a") do
        assert_equal(a, 1)
        assert_equal(b, 2)
  end
  assert_number( db2:close() )

end




















































lunit.main()








|
|







 








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
....
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
    IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
    CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
    TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
    SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

--]]--------------------------------------------------------------------------

-- extended for LuaSQLite3, and for Lua 5.2 through 5.4 (using lunitx)
-- Copyright (c) 2005-18 Doug Currie
-- Same license as above

local sqlite3 = require(arg[1]) -- "lsqlite3complete" or "lsqlite3"

local os = os

--local lunit = require "lunitx"
................................................................................
  for a, b in db2:urows("SELECT * FROM test1 ORDER BY a") do
        assert_equal(a, 1)
        assert_equal(b, 2)
  end
  assert_number( db2:close() )

end

--------------------------------------
-- Test for defect ticket d54dc056  --
--------------------------------------

local db_lgblob = lunit_TestCase("Large Blob")

function db_lgblob.setup()
  db_lgblob.filename = "/tmp/__lua-sqlite3-20180630t." .. os.time()
  db_lgblob.db = assert_userdata( sqlite3.open(db_lgblob.filename) )
  assert_equal( sqlite3.OK,
   db_lgblob.db:exec("CREATE TABLE IF NOT EXISTS test ( "..
                     "filename TEXT PRIMARY KEY, ISOtime TEXT, wav BLOB )") )
end

function db_lgblob.teardown()
  assert( db_lgblob.db:close() )
  os.remove(db_lgblob.filename)
end

function db_lgblob.test()
    local db = db_lgblob.db
    local lb = string.rep('Hello\0SQLite\0', 1000000) -- 13Mbytes

    local stat = db:prepare(
            "INSERT OR REPLACE INTO test (filename, ISOtime, wav) VALUES (?,?,?)")
    stat:bind(1, 'fn')
    stat:bind(2, '2018-06-30')
    stat:bind_blob(3, lb)
    rc = stat:step()
    assert_equal( sqlite3.DONE, rc )
    if rc == sqlite3.DONE then
      stat:finalize()
      db:close()
    end

    db_lgblob.db = assert_userdata( sqlite3.open(db_lgblob.filename) )
    db = db_lgblob.db

    stat = db:prepare("SELECT wav FROM test WHERE filename = ?")
    stat:bind(1,'fn')
    stat:step()
    local body = stat:get_value(0)

    assert_equal( lb, body )
    assert( string.len(lb) == (13 * 1000000) )
end

-------------------------
-- Run the unit tests  --
-------------------------

lunit.main()