2005-06-25 23:31:48 +04:00
|
|
|
# 2005 June 25
|
|
|
|
#
|
|
|
|
# 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 file is testing the interaction of SQLite manifest types
|
|
|
|
# with Tcl dual-representations.
|
|
|
|
#
|
2006-01-17 12:35:01 +03:00
|
|
|
# $Id: types3.test,v 1.5 2006/01/17 09:35:03 danielk1977 Exp $
|
2005-06-25 23:31:48 +04:00
|
|
|
#
|
|
|
|
|
|
|
|
set testdir [file dirname $argv0]
|
|
|
|
source $testdir/tester.tcl
|
|
|
|
|
|
|
|
# A variable with only a string representation comes in as TEXT
|
|
|
|
do_test types3-1.1 {
|
|
|
|
set V {}
|
|
|
|
append V {}
|
2006-01-17 12:35:01 +03:00
|
|
|
concat [tcl_variable_type V] [execsql {SELECT typeof(:V)}]
|
2005-06-25 23:31:48 +04:00
|
|
|
} {string text}
|
|
|
|
|
|
|
|
# A variable with an integer representation comes in as INTEGER
|
|
|
|
do_test types3-1.2 {
|
|
|
|
set V [expr {1+2}]
|
2006-01-17 12:35:01 +03:00
|
|
|
concat [tcl_variable_type V] [execsql {SELECT typeof(:V)}]
|
2005-06-25 23:31:48 +04:00
|
|
|
} {int integer}
|
|
|
|
do_test types3-1.3 {
|
|
|
|
set V [expr {1+123456789012345}]
|
2006-01-17 12:35:01 +03:00
|
|
|
concat [tcl_variable_type V] [execsql {SELECT typeof(:V)}]
|
2005-06-25 23:31:48 +04:00
|
|
|
} {wideInt integer}
|
|
|
|
|
|
|
|
# A double variable comes in as REAL
|
|
|
|
do_test types3-1.4 {
|
|
|
|
set V [expr {1.0+1}]
|
2006-01-17 12:35:01 +03:00
|
|
|
concat [tcl_variable_type V] [execsql {SELECT typeof(:V)}]
|
2005-06-25 23:31:48 +04:00
|
|
|
} {double real}
|
|
|
|
|
|
|
|
# A byte-array variable comes in a BLOB if it has no string representation
|
|
|
|
# or as TEXT if there is a string representation.
|
|
|
|
#
|
|
|
|
do_test types3-1.5 {
|
|
|
|
set V [binary format a3 abc]
|
2006-01-17 12:35:01 +03:00
|
|
|
concat [tcl_variable_type V] [execsql {SELECT typeof(:V)}]
|
2005-06-25 23:31:48 +04:00
|
|
|
} {bytearray blob}
|
|
|
|
do_test types3-1.6 {
|
|
|
|
set V "abc"
|
|
|
|
binary scan $V a3 x
|
2006-01-17 12:35:01 +03:00
|
|
|
concat [tcl_variable_type V] [execsql {SELECT typeof(:V)}]
|
2005-06-25 23:31:48 +04:00
|
|
|
} {bytearray text}
|
|
|
|
|
|
|
|
# Check to make sure return values are of the right types.
|
|
|
|
#
|
2006-01-16 19:24:25 +03:00
|
|
|
ifcapable bloblit {
|
|
|
|
do_test types3-2.1 {
|
|
|
|
set V [db one {SELECT x'616263'}]
|
|
|
|
tcl_variable_type V
|
|
|
|
} bytearray
|
|
|
|
}
|
2005-06-25 23:31:48 +04:00
|
|
|
do_test types3-2.2 {
|
|
|
|
set V [db one {SELECT 123}]
|
|
|
|
tcl_variable_type V
|
|
|
|
} int
|
|
|
|
do_test types3-2.3 {
|
|
|
|
set V [db one {SELECT 1234567890123456}]
|
|
|
|
tcl_variable_type V
|
|
|
|
} wideInt
|
2005-11-01 18:48:24 +03:00
|
|
|
do_test types3-2.4.1 {
|
|
|
|
set V [db one {SELECT 1234567890123456.1}]
|
|
|
|
tcl_variable_type V
|
2005-11-15 01:29:05 +03:00
|
|
|
} double
|
2005-11-01 18:48:24 +03:00
|
|
|
do_test types3-2.4.2 {
|
|
|
|
set V [db one {SELECT 1234567890123.456}]
|
2005-06-25 23:31:48 +04:00
|
|
|
tcl_variable_type V
|
|
|
|
} double
|
|
|
|
do_test types3-2.5 {
|
|
|
|
set V [db one {SELECT '1234567890123456.0'}]
|
|
|
|
tcl_variable_type V
|
|
|
|
} {}
|
|
|
|
do_test types3-2.6 {
|
|
|
|
set V [db one {SELECT NULL}]
|
|
|
|
tcl_variable_type V
|
|
|
|
} {}
|
|
|
|
|
|
|
|
finish_test
|