SQLite

Check-in [7c094c80b2]
Login

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

Overview
Comment:Fix the bind.test test script so that the tests for zeros embedded in strings work correctly for UTF-16 encoded databases. (CVS 5020)
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 7c094c80b2439480ffc680b2d63031d1033b266a
User & Date: drh 2008-04-16 16:11:49.000
Context
2008-04-16
23:39
Clear a global variable in the incrblob.test script. Ticket #3062. (CVS 5021) (check-in: 1c19854ae7 user: drh tags: trunk)
16:11
Fix the bind.test test script so that the tests for zeros embedded in strings work correctly for UTF-16 encoded databases. (CVS 5020) (check-in: 7c094c80b2 user: drh tags: trunk)
15:39
Version 3.5.8 (CVS 5019) (check-in: 6a2e3eb26a user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to test/bind.test.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 2003 September 6
#
# 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.
#
#***********************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this script testing the sqlite_bind API.
#
# $Id: bind.test,v 1.41 2008/04/16 12:58:54 drh Exp $
#

set testdir [file dirname $argv0]
source $testdir/tester.tcl

proc sqlite_step {stmt N VALS COLS} {
  upvar VALS vals













|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 2003 September 6
#
# 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.
#
#***********************************************************************
# This file implements regression tests for SQLite library.  The
# focus of this script testing the sqlite_bind API.
#
# $Id: bind.test,v 1.42 2008/04/16 16:11:49 drh Exp $
#

set testdir [file dirname $argv0]
source $testdir/tester.tcl

proc sqlite_step {stmt N VALS COLS} {
  upvar VALS vals
271
272
273
274
275
276
277





278
279

280
281








282

283
284
285
286
287
288
289
do_test bind-6.4 {
  db eval {DELETE FROM t1}
  sqlite3_bind_text $VM 1 hello\000there\000 12
  sqlite3_bind_text $VM 2 hello\000there\000 11
  sqlite3_bind_text $VM 3 hello\000there\000 -1
  sqlite_step $VM N VALUES COLNAMES
  sqlite3_reset $VM





  execsql {SELECT  hex(a), hex(b), hex(c) FROM t1}
} {68656C6C6F00746865726500 68656C6C6F007468657265 68656C6C6F}

do_test bind-6.5 {
  execsql {SELECT * FROM t1}








} {hello hello hello}

do_test bind-6.6 {
  execsql {SELECT typeof(a), typeof(b), typeof(c) FROM t1}
} {text text text}
do_test bind-6.7 {
  execsql {
    DELETE FROM t1;
  }







>
>
>
>
>
|
|
>
|
|
>
>
>
>
>
>
>
>
|
>







271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
do_test bind-6.4 {
  db eval {DELETE FROM t1}
  sqlite3_bind_text $VM 1 hello\000there\000 12
  sqlite3_bind_text $VM 2 hello\000there\000 11
  sqlite3_bind_text $VM 3 hello\000there\000 -1
  sqlite_step $VM N VALUES COLNAMES
  sqlite3_reset $VM
  execsql {SELECT * FROM t1}
} {hello hello hello}
set enc [db eval {PRAGMA encoding}]
if {$enc=="UTF-8"} {
  do_test bind-6.5 {
    execsql {SELECT  hex(a), hex(b), hex(c) FROM t1}
  } {68656C6C6F00746865726500 68656C6C6F007468657265 68656C6C6F}
} elseif {$enc=="UTF-16le"} {
  do_test bind-6.5 {
    execsql {SELECT  hex(a), hex(b), hex(c) FROM t1}
  } {680065006C006C006F000000740068006500720065000000 680065006C006C006F00000074006800650072006500 680065006C006C006F00}
} elseif {$enc=="UTF-16be"} {
  do_test bind-6.5 {
    execsql {SELECT  hex(a), hex(b), hex(c) FROM t1}
  } {00680065006C006C006F0000007400680065007200650000 00680065006C006C006F000000740068006500720065 00680065006C006C006F}
} else {
  do_test bind-6.5 {
    set "Unknown database encoding: $::enc"
  } {}
}
do_test bind-6.6 {
  execsql {SELECT typeof(a), typeof(b), typeof(c) FROM t1}
} {text text text}
do_test bind-6.7 {
  execsql {
    DELETE FROM t1;
  }
307
308
309
310
311
312
313

314
315
316









317
318
319
320
321
322
323
    sqlite3_bind_text16 $VM 1 [encoding convertto unicode hi\000yall\000] 16
    sqlite3_bind_text16 $VM 2 [encoding convertto unicode hi\000yall\000] 14
    sqlite3_bind_text16 $VM 3 [encoding convertto unicode hi\000yall\000] -1
    sqlite_step $VM N VALUES COLNAMES
    sqlite3_reset $VM
    execsql {SELECT * FROM t1}
  } {hi hi hi}

  do_test bind-7.4 {
    execsql {SELECT hex(a), hex(b), hex(c) FROM t1}
  } {68690079616C6C00 68690079616C6C 6869}









  do_test bind-7.5 {
    execsql {SELECT typeof(a), typeof(b), typeof(c) FROM t1}
  } {text text text}
}
do_test bind-7.99 {
  execsql {DELETE FROM t1;}
} {}







>
|
|
|
>
>
>
>
>
>
>
>
>







322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
    sqlite3_bind_text16 $VM 1 [encoding convertto unicode hi\000yall\000] 16
    sqlite3_bind_text16 $VM 2 [encoding convertto unicode hi\000yall\000] 14
    sqlite3_bind_text16 $VM 3 [encoding convertto unicode hi\000yall\000] -1
    sqlite_step $VM N VALUES COLNAMES
    sqlite3_reset $VM
    execsql {SELECT * FROM t1}
  } {hi hi hi}
  if {$enc=="UTF-8"} {
    do_test bind-7.4 {
      execsql {SELECT hex(a), hex(b), hex(c) FROM t1}
    } {68690079616C6C00 68690079616C6C 6869}
  } elseif {$enc=="UTF-16le"} {
    do_test bind-7.4 {
      execsql {SELECT hex(a), hex(b), hex(c) FROM t1}
    } {680069000000790061006C006C000000 680069000000790061006C006C00 68006900}
  } elseif {$enc=="UTF-16be"} {
    do_test bind-7.4 {
      execsql {SELECT hex(a), hex(b), hex(c) FROM t1}
    } {00680069000000790061006C006C0000 00680069000000790061006C006C 00680069}
  }
  do_test bind-7.5 {
    execsql {SELECT typeof(a), typeof(b), typeof(c) FROM t1}
  } {text text text}
}
do_test bind-7.99 {
  execsql {DELETE FROM t1;}
} {}