1# 2005 June 25 2# 3# The author disclaims copyright to this source code. In place of 4# 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. The focus 12# of this file is testing the interaction of SQLite manifest types 13# with Tcl dual-representations. 14# 15# $Id: types3.test,v 1.6 2007/05/03 16:31:26 danielk1977 Exp $ 16# 17 18set testdir [file dirname $argv0] 19source $testdir/tester.tcl 20 21# A variable with only a string representation comes in as TEXT 22do_test types3-1.1 { 23 set V {} 24 append V {} 25 concat [tcl_variable_type V] [execsql {SELECT typeof(:V)}] 26} {string text} 27 28# A variable with an integer representation comes in as INTEGER 29do_test types3-1.2 { 30 set V [expr {int(1+2)}] 31 concat [tcl_variable_type V] [execsql {SELECT typeof(:V)}] 32} {int integer} 33do_test types3-1.3 { 34 set V [expr {1+123456789012345}] 35 concat [tcl_variable_type V] [execsql {SELECT typeof(:V)}] 36} {wideInt integer} 37 38# A double variable comes in as REAL 39do_test types3-1.4 { 40 set V [expr {1.0+1}] 41 concat [tcl_variable_type V] [execsql {SELECT typeof(:V)}] 42} {double real} 43 44# A byte-array variable comes in a BLOB if it has no string representation 45# or as TEXT if there is a string representation. 46# 47do_test types3-1.5 { 48 set V [binary format a3 abc] 49 concat [tcl_variable_type V] [execsql {SELECT typeof(:V)}] 50} {bytearray blob} 51do_test types3-1.6 { 52 set V "abc" 53 binary scan $V a3 x 54 concat [tcl_variable_type V] [execsql {SELECT typeof(:V)}] 55} {bytearray text} 56 57# Check to make sure return values are of the right types. 58# 59ifcapable bloblit { 60 do_test types3-2.1 { 61 set V [db one {SELECT x'616263'}] 62 tcl_variable_type V 63 } bytearray 64} 65do_test types3-2.2 { 66 set V [db one {SELECT 123}] 67 tcl_variable_type V 68} int 69do_test types3-2.3 { 70 set V [db one {SELECT 1234567890123456}] 71 tcl_variable_type V 72} wideInt 73do_test types3-2.4.1 { 74 set V [db one {SELECT 1234567890123456.1}] 75 tcl_variable_type V 76} double 77do_test types3-2.4.2 { 78 set V [db one {SELECT 1234567890123.456}] 79 tcl_variable_type V 80} double 81do_test types3-2.5 { 82 set V [db one {SELECT '1234567890123456.0'}] 83 tcl_variable_type V 84} {} 85do_test types3-2.6 { 86 set V [db one {SELECT NULL}] 87 tcl_variable_type V 88} {} 89 90finish_test 91