⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 capi3c.test

📁 最新的sqlite3.6.2源代码
💻 TEST
📖 第 1 页 / 共 3 页
字号:
  lappend lens [string length [lindex $strings $i]]}do_test $test.3 {  set bytes [list]  set lens [list]  foreach i $idxlist {    lappend bytes [sqlite3_column_bytes $STMT $i]  }  set bytes} $lens# bytes16ifcapable {utf16} {  set lens [list]  foreach i $::idxlist {    lappend lens [expr 2 * [string length [lindex $strings $i]]]  }  do_test $test.4 {    set bytes [list]    set lens [list]    foreach i $idxlist {      lappend bytes [sqlite3_column_bytes16 $STMT $i]    }    set bytes  } $lens}# Blobdo_test $test.5 {  set utf8 [list]  foreach i $idxlist {lappend utf8 [sqlite3_column_blob $STMT $i]}  set utf8} $strings# UTF-8do_test $test.6 {  set utf8 [list]  foreach i $idxlist {lappend utf8 [sqlite3_column_text $STMT $i]}  set utf8} $strings# Floatsdo_test $test.7 {  set utf8 [list]  foreach i $idxlist {lappend utf8 [sqlite3_column_double $STMT $i]}  set utf8} $doubles# UTF-16ifcapable {utf16} {  do_test $test.8 {    set utf8 [list]    foreach i $idxlist {lappend utf8 [utf8 [sqlite3_column_text16 $STMT $i]]}    set utf8  } $strings}# Integersdo_test $test.9 {  set ints [list]  foreach i $idxlist {lappend ints [sqlite3_column_int $STMT $i]}  set ints} $ints# Floatsdo_test $test.10 {  set utf8 [list]  foreach i $idxlist {lappend utf8 [sqlite3_column_double $STMT $i]}  set utf8} $doubles# UTF-8do_test $test.11 {  set utf8 [list]  foreach i $idxlist {lappend utf8 [sqlite3_column_text $STMT $i]}  set utf8} $strings# Typesdo_test $test.12 {  set types [list]  foreach i $idxlist {lappend types [sqlite3_column_type $STMT $i]}  set types} $types# Test that an out of range request returns the equivalent of NULLdo_test $test.13 {  sqlite3_column_int $STMT -1} {0}do_test $test.13 {  sqlite3_column_text $STMT -1} {}}ifcapable !floatingpoint {  finish_test  return}do_test capi3c-5.0 {  execsql {    CREATE TABLE t1(a VARINT, b BLOB, c VARCHAR(16));    INSERT INTO t1 VALUES(1, 2, 3);    INSERT INTO t1 VALUES('one', 'two', NULL);    INSERT INTO t1 VALUES(1.2, 1.3, 1.4);  }  set sql "SELECT * FROM t1"  set STMT [sqlite3_prepare_v2 $DB $sql -1 TAIL]  sqlite3_column_count $STMT} 3check_header $STMT capi3c-5.1 {a b c} {VARINT BLOB VARCHAR(16)}check_origin_header $STMT capi3c-5.1 {main main main} {t1 t1 t1} {a b c}do_test capi3c-5.2 {  sqlite3_step $STMT} SQLITE_ROWcheck_header $STMT capi3c-5.3 {a b c} {VARINT BLOB VARCHAR(16)}check_origin_header $STMT capi3c-5.3 {main main main} {t1 t1 t1} {a b c}check_data $STMT capi3c-5.4 {INTEGER INTEGER TEXT} {1 2 3} {1.0 2.0 3.0} {1 2 3}do_test capi3c-5.5 {  sqlite3_step $STMT} SQLITE_ROWcheck_header $STMT capi3c-5.6 {a b c} {VARINT BLOB VARCHAR(16)}check_origin_header $STMT capi3c-5.6 {main main main} {t1 t1 t1} {a b c}check_data $STMT capi3c-5.7 {TEXT TEXT NULL} {0 0 0} {0.0 0.0 0.0} {one two {}}do_test capi3c-5.8 {  sqlite3_step $STMT} SQLITE_ROWcheck_header $STMT capi3c-5.9 {a b c} {VARINT BLOB VARCHAR(16)}check_origin_header $STMT capi3c-5.9 {main main main} {t1 t1 t1} {a b c}check_data $STMT capi3c-5.10 {FLOAT FLOAT TEXT} {1 1 1} {1.2 1.3 1.4} {1.2 1.3 1.4}do_test capi3c-5.11 {  sqlite3_step $STMT} SQLITE_DONEdo_test capi3c-5.12 {  sqlite3_finalize $STMT} SQLITE_OKdo_test capi3c-5.20 {  set sql "SELECT a, sum(b), max(c) FROM t1 GROUP BY a"  set STMT [sqlite3_prepare_v2 $DB $sql -1 TAIL]  sqlite3_column_count $STMT} 3check_header $STMT capi3c-5.21 {a sum(b) max(c)} {VARINT {} {}}check_origin_header $STMT capi3c-5.22 {main {} {}} {t1 {} {}} {a {} {}}do_test capi3c-5.23 {  sqlite3_finalize $STMT} SQLITE_OKset ::ENC [execsql {pragma encoding}]db closedo_test capi3c-6.0 {  sqlite3 db test.db  set DB [sqlite3_connection_pointer db]  sqlite3_key $DB xyzzy  set sql {SELECT a FROM t1 order by rowid}  set STMT [sqlite3_prepare_v2 $DB $sql -1 TAIL]  expr 0} {0}do_test capi3c-6.1 {  db cache flush  sqlite3_close $DB} {SQLITE_BUSY}do_test capi3c-6.2 {  sqlite3_step $STMT} {SQLITE_ROW}check_data $STMT capi3c-6.3 {INTEGER} {1} {1.0} {1}do_test capi3c-6.3 {  sqlite3_finalize $STMT} {SQLITE_OK}do_test capi3c-6.4 {  db cache flush  sqlite3_close $DB} {SQLITE_OK}do_test capi3c-6.99-misuse {  db close} {}# This procedure sets the value of the file-format in file 'test.db'# to $newval. Also, the schema cookie is incremented.# proc set_file_format {newval} {  hexio_write test.db 44 [hexio_render_int32 $newval]  set schemacookie [hexio_get_int [hexio_read test.db 40 4]]  incr schemacookie  hexio_write test.db 40 [hexio_render_int32 $schemacookie]  return {}}# This procedure returns the value of the file-format in file 'test.db'.# proc get_file_format {{fname test.db}} {  return [hexio_get_int [hexio_read $fname 44 4]]}if {![sqlite3 -has-codec]} {  # Test what happens when the library encounters a newer file format.  do_test capi3c-7.1 {    set_file_format 5  } {}  do_test capi3c-7.2 {    sqlite3 db test.db    catchsql {      SELECT * FROM sqlite_master;    }  } {1 {unsupported file format}}  db close}if {![sqlite3 -has-codec]} {  # Now test that the library correctly handles bogus entries in the  # sqlite_master table (schema corruption).  do_test capi3c-8.1 {    file delete -force test.db test.db-journal    sqlite3 db test.db    execsql {      CREATE TABLE t1(a);    }    db close  } {}  do_test capi3c-8.2 {    sqlite3 db test.db    execsql {      PRAGMA writable_schema=ON;      INSERT INTO sqlite_master VALUES(NULL,NULL,NULL,NULL,NULL);    }    db close  } {}  do_test capi3c-8.3 {    sqlite3 db test.db    catchsql {      SELECT * FROM sqlite_master;    }  } {1 {malformed database schema (?)}}  do_test capi3c-8.4 {    # Build a 5-field row record. The first field is a string 'table', and    # subsequent fields are all NULL.    db close    file delete -force test.db test.db-journal    sqlite3 db test.db    execsql {      CREATE TABLE t1(a);      PRAGMA writable_schema=ON;      INSERT INTO sqlite_master VALUES('table',NULL,NULL,NULL,NULL);    }    db close  } {};  do_test capi3c-8.5 {    sqlite3 db test.db    catchsql {      SELECT * FROM sqlite_master;    }  } {1 {malformed database schema (?)}}  db close}file delete -force test.dbfile delete -force test.db-journal# Test the english language string equivalents for sqlite error codesset code2english [list \SQLITE_OK         {not an error} \SQLITE_ERROR      {SQL logic error or missing database} \SQLITE_PERM       {access permission denied} \SQLITE_ABORT      {callback requested query abort} \SQLITE_BUSY       {database is locked} \SQLITE_LOCKED     {database table is locked} \SQLITE_NOMEM      {out of memory} \SQLITE_READONLY   {attempt to write a readonly database} \SQLITE_INTERRUPT  {interrupted} \SQLITE_IOERR      {disk I/O error} \SQLITE_CORRUPT    {database disk image is malformed} \SQLITE_FULL       {database or disk is full} \SQLITE_CANTOPEN   {unable to open database file} \SQLITE_EMPTY      {table contains no data} \SQLITE_SCHEMA     {database schema has changed} \SQLITE_CONSTRAINT {constraint failed} \SQLITE_MISMATCH   {datatype mismatch} \SQLITE_MISUSE     {library routine called out of sequence} \SQLITE_NOLFS      {large file support is disabled} \SQLITE_AUTH       {authorization denied} \SQLITE_FORMAT     {auxiliary database format error} \SQLITE_RANGE      {bind or column index out of range} \SQLITE_NOTADB     {file is encrypted or is not a database} \unknownerror      {unknown error} \]set test_number 1foreach {code english} $code2english {  do_test capi3c-9.$test_number "sqlite3_test_errstr $code" $english  incr test_number}# Test the error message when a "real" out of memory occurs.ifcapable memdebug {  do_test capi3c-10-1 {    sqlite3 db test.db    set DB [sqlite3_connection_pointer db]    sqlite3_memdebug_fail 0    catchsql {      select * from sqlite_master;    }  } {1 {out of memory}}  do_test capi3c-10-2 {    sqlite3_errmsg $::DB  } {out of memory}  ifcapable {utf16} {    do_test capi3c-10-3 {      utf8 [sqlite3_errmsg16 $::DB]    } {out of memory}  }  db close  sqlite3_memdebug_fail -1}# The following tests - capi3c-11.* - test that a COMMIT or ROLLBACK# statement issued while there are still outstanding VMs that are part of# the transaction fails.sqlite3 db test.dbset DB [sqlite3_connection_pointer db]sqlite_register_test_function $DB funcdo_test capi3c-11.1 {  execsql {    BEGIN;    CREATE TABLE t1(a, b);    INSERT INTO t1 VALUES(1, 'int');    INSERT INTO t1 VALUES(2, 'notatype');  }} {}do_test capi3c-11.1.1 {  sqlite3_get_autocommit $DB} 0do_test capi3c-11.2 {  set STMT [sqlite3_prepare_v2 $DB "SELECT func(b, a) FROM t1" -1 TAIL]  sqlite3_step $STMT} {SQLITE_ROW}do_test capi3c-11.3 {  catchsql {    COMMIT;  }} {1 {cannot commit transaction - SQL statements in progress}}do_test capi3c-11.3.1 {  sqlite3_get_autocommit $DB} 0do_test capi3c-11.4 {  sqlite3_step $STMT} {SQLITE_ERROR}do_test capi3c-11.5 {  sqlite3_finalize $STMT} {SQLITE_ERROR}do_test capi3c-11.6 {  catchsql {    SELECT * FROM t1;  }} {0 {1 int 2 notatype}}do_test capi3c-11.6.1 {  sqlite3_get_autocommit $DB} 0do_test capi3c-11.7 {  catchsql {    COMMIT;  }} {0 {}}do_test capi3c-11.7.1 {  sqlite3_get_autocommit $DB} 1do_test capi3c-11.8 {  execsql {    CREATE TABLE t2(a);    INSERT INTO t2 VALUES(1);    INSERT INTO t2 VALUES(2);    BEGIN;    INSERT INTO t2 VALUES(3);  }} {}do_test capi3c-11.8.1 {  sqlite3_get_autocommit $DB} 0do_test capi3c-11.9 {  set STMT [sqlite3_prepare_v2 $DB "SELECT a FROM t2" -1 TAIL]  sqlite3_step $STMT} {SQLITE_ROW}do_test capi3c-11.9.1 {  sqlite3_get_autocommit $DB} 0do_test capi3c-11.9.2 {  catchsql {    ROLLBACK;  }} {1 {cannot rollback transaction - SQL statements in progress}}do_test capi3c-11.9.3 {  sqlite3_get_autocommit $DB} 0do_test capi3c-11.10 {  sqlite3_step $STMT} {SQLITE_ROW}do_test capi3c-11.11 {  sqlite3_step $STMT} {SQLITE_ROW}do_test capi3c-11.12 {  sqlite3_step $STMT} {SQLITE_DONE}do_test capi3c-11.13 {  sqlite3_finalize $STMT} {SQLITE_OK}do_test capi3c-11.14 {  execsql {    SELECT a FROM t2;  }} {1 2 3}do_test capi3c-11.14.1 {  sqlite3_get_autocommit $DB} 0do_test capi3c-11.15 {  catchsql {    ROLLBACK;  }} {0 {}}do_test capi3c-11.15.1 {  sqlite3_get_autocommit $DB} 1do_test capi3c-11.16 {  execsql {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -