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 Side-by-Side Diffs Ignore Whitespace Patch

Changes to test/tests-sqlite3.lua.

    22     22       IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
    23     23       CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
    24     24       TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
    25     25       SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    26     26   
    27     27   --]]--------------------------------------------------------------------------
    28     28   
    29         --- extended for LuaSQLite3, and for Lua 5.2 (using lunitx)
    30         --- Copyright (c) 2005-13 Doug Currie
           29  +-- extended for LuaSQLite3, and for Lua 5.2 through 5.4 (using lunitx)
           30  +-- Copyright (c) 2005-18 Doug Currie
    31     31   -- Same license as above
    32     32   
    33     33   local sqlite3 = require(arg[1]) -- "lsqlite3complete" or "lsqlite3"
    34     34   
    35     35   local os = os
    36     36   
    37     37   --local lunit = require "lunitx"
................................................................................
  1239   1239     for a, b in db2:urows("SELECT * FROM test1 ORDER BY a") do
  1240   1240           assert_equal(a, 1)
  1241   1241           assert_equal(b, 2)
  1242   1242     end
  1243   1243     assert_number( db2:close() )
  1244   1244   
  1245   1245   end
         1246  +
         1247  +--------------------------------------
         1248  +-- Test for defect ticket d54dc056  --
         1249  +--------------------------------------
         1250  +
         1251  +local db_lgblob = lunit_TestCase("Large Blob")
         1252  +
         1253  +function db_lgblob.setup()
         1254  +  db_lgblob.filename = "/tmp/__lua-sqlite3-20180630t." .. os.time()
         1255  +  db_lgblob.db = assert_userdata( sqlite3.open(db_lgblob.filename) )
         1256  +  assert_equal( sqlite3.OK,
         1257  +   db_lgblob.db:exec("CREATE TABLE IF NOT EXISTS test ( "..
         1258  +                     "filename TEXT PRIMARY KEY, ISOtime TEXT, wav BLOB )") )
         1259  +end
         1260  +
         1261  +function db_lgblob.teardown()
         1262  +  assert( db_lgblob.db:close() )
         1263  +  os.remove(db_lgblob.filename)
         1264  +end
         1265  +
         1266  +function db_lgblob.test()
         1267  +    local db = db_lgblob.db
         1268  +    local lb = string.rep('Hello\0SQLite\0', 1000000) -- 13Mbytes
         1269  +
         1270  +    local stat = db:prepare(
         1271  +            "INSERT OR REPLACE INTO test (filename, ISOtime, wav) VALUES (?,?,?)")
         1272  +    stat:bind(1, 'fn')
         1273  +    stat:bind(2, '2018-06-30')
         1274  +    stat:bind_blob(3, lb)
         1275  +    rc = stat:step()
         1276  +    assert_equal( sqlite3.DONE, rc )
         1277  +    if rc == sqlite3.DONE then
         1278  +      stat:finalize()
         1279  +      db:close()
         1280  +    end
         1281  +
         1282  +    db_lgblob.db = assert_userdata( sqlite3.open(db_lgblob.filename) )
         1283  +    db = db_lgblob.db
         1284  +
         1285  +    stat = db:prepare("SELECT wav FROM test WHERE filename = ?")
         1286  +    stat:bind(1,'fn')
         1287  +    stat:step()
         1288  +    local body = stat:get_value(0)
         1289  +
         1290  +    assert_equal( lb, body )
         1291  +    assert( string.len(lb) == (13 * 1000000) )
         1292  +end
         1293  +
         1294  +-------------------------
         1295  +-- Run the unit tests  --
         1296  +-------------------------
  1246   1297   
  1247   1298   lunit.main()
  1248   1299