CoolFace
Modelpublic

AryaWu/sqlite

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes
columncount.test63 linesDownload Raw Back to test
1# 2021 February 152#3# The author disclaims copyright to this source code.  In place of4# a legal notice, here is a blessing:5#6#    May you do good and not evil.7#    May you find forgiveness for yourself and forgive others.8#    May you share freely, never taking more than you give.9#10#***********************************************************************11# This file implements regression tests for SQLite library.  The12# focus of this file is testing the sqlite3_column_count() API.13#14 15set testdir [file dirname $argv0]16source $testdir/tester.tcl17set testprefix columncount18 19# If SQLITE_OMIT_ALTERTABLE is defined, omit this file.20ifcapable !altertable {21  finish_test22  return23}24 25proc do_ccsql_test {tn sql res} {26 27  uplevel [list do_test $tn [subst -nocommands {28    set stmt [sqlite3_prepare_v2 db {$sql} -1 dummy]29    set res [sqlite3_column_count [set stmt]]30    while {[sqlite3_step [set stmt]]=="SQLITE_ROW"} {31      for {set i 0} {[set i] < [sqlite3_data_count [set stmt]]} {incr i} {32        lappend res [sqlite3_column_text [set stmt] [set i]]33      }34    }35  36    set rc [sqlite3_finalize [set stmt]]37    if {[set rc]!="SQLITE_OK"} {38      error [sqlite3_errmsg db]39    }40 41    set res42  }] [list {*}$res]]43 44}45 46do_execsql_test 1.0 {47  CREATE TABLE t1(x, y, z);48  INSERT INTO t1 VALUES('a', 'b', 'c');49}50 51do_ccsql_test 1.1 { SELECT * FROM t1 }      {3    a b c}52do_ccsql_test 1.2 { CREATE TABLE t2(a, b) } {0}53 54do_ccsql_test 1.3 { ALTER TABLE t2 RENAME TO t3 } {0}55do_ccsql_test 1.4 { ALTER TABLE t3 RENAME b TO ccc } {0}56do_ccsql_test 1.5 { ALTER TABLE t3 ADD COLUMN d } {0}57 58do_ccsql_test 1.6 { DROP TABLE t3 } {0}59 60 61 62finish_test63