xref: /sqlite-3.40.0/test/misc6.test (revision af30469d)
1f0313813Sdrh# 2006 September 4
2f0313813Sdrh#
3f0313813Sdrh# The author disclaims copyright to this source code.  In place of
4f0313813Sdrh# a legal notice, here is a blessing:
5f0313813Sdrh#
6f0313813Sdrh#    May you do good and not evil.
7f0313813Sdrh#    May you find forgiveness for yourself and forgive others.
8f0313813Sdrh#    May you share freely, never taking more than you give.
9f0313813Sdrh#
10f0313813Sdrh#***********************************************************************
11f0313813Sdrh# This file implements regression tests for SQLite library.
12f0313813Sdrh#
13f0313813Sdrh# This file implements tests to make sure sqlite3_value_text()
14f0313813Sdrh# always returns a null-terminated string.
15f0313813Sdrh#
16*af30469dSdrh# $Id: misc6.test,v 1.3 2007/04/23 23:56:32 drh Exp $
17f0313813Sdrh
18f0313813Sdrhset testdir [file dirname $argv0]
19f0313813Sdrhsource $testdir/tester.tcl
20f0313813Sdrh
21f0313813Sdrhdo_test misc6-1.1 {
22f0313813Sdrh  set DB [sqlite3_connection_pointer db]
23f0313813Sdrh  sqlite3_create_function $DB
24f0313813Sdrh  set STMT [sqlite3_prepare $DB {SELECT hex8(?)} -1 DUMMY]
25f0313813Sdrh  set sqlite_static_bind_value {0123456789}
26f0313813Sdrh  set sqlite_static_bind_nbyte 5
27f0313813Sdrh  sqlite_bind $STMT 1 {} static-nbytes
28f0313813Sdrh  sqlite3_step $STMT
29f0313813Sdrh} SQLITE_ROW
30f0313813Sdrhdo_test misc6-1.2 {
31f0313813Sdrh  sqlite3_column_text $STMT 0
32f0313813Sdrh} {3031323334}
33*af30469dSdrhifcapable utf16 {
34f0313813Sdrh  do_test misc6-1.3 {
35f0313813Sdrh    sqlite3_finalize $STMT
36f0313813Sdrh    set STMT [sqlite3_prepare $DB {SELECT hex16(?)} -1 DUMMY]
37f0313813Sdrh    set sqlite_static_bind_value {0123456789}
38f0313813Sdrh    set sqlite_static_bind_nbyte 5
39f0313813Sdrh    sqlite_bind $STMT 1 {} static-nbytes
40f0313813Sdrh    sqlite3_step $STMT
41f0313813Sdrh  } SQLITE_ROW
42f0313813Sdrh  do_test misc6-1.4 {
43f0313813Sdrh    sqlite3_column_text $STMT 0
44f0313813Sdrh  } {00300031003200330034}
45*af30469dSdrh}
46b2b49962Sdrhsqlite3_finalize $STMT
47f0313813Sdrh
48f0313813Sdrhfinish_test
49