blob: 807ae84f9d2dbe5896b7348eefd3556920f8dcbf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
# 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.
#
# $Id: types3.test,v 1.8 2008/04/28 13:02:58 drh Exp $
#
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 x
concat [tcl_variable_type V] [execsql {SELECT typeof(:V)}]
} {string text}
# A variable with an integer representation comes in as INTEGER
do_test types3-1.2 {
set V [expr {int(1+2)}]
concat [tcl_variable_type V] [execsql {SELECT typeof(:V)}]
} {int integer}
set V [expr {1+12345678012345}]
if {[tcl_variable_type V]=="wideInt"} {
do_test types3-1.3 {
set V [expr {1+123456789012345}]
concat [tcl_variable_type V] [execsql {SELECT typeof(:V)}]
} {wideInt integer}
} else {
do_test types3-1.3 {
set V [expr {1+123456789012345}]
concat [tcl_variable_type V] [execsql {SELECT typeof(:V)}]
} {int integer}
}
# A double variable comes in as REAL
do_test types3-1.4 {
set V [expr {1.0+1}]
concat [tcl_variable_type V] [execsql {SELECT typeof(:V)}]
} {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]
concat [tcl_variable_type V] [execsql {SELECT typeof(:V)}]
} {bytearray blob}
do_test types3-1.6 {
set V "abc"
binary scan $V a3 x
concat [tcl_variable_type V] [execsql {SELECT typeof(:V)}]
} {bytearray text}
# Check to make sure return values are of the right types.
#
ifcapable bloblit {
do_test types3-2.1 {
set V [db one {SELECT x'616263'}]
tcl_variable_type V
} bytearray
}
do_test types3-2.2 {
set V [db one {SELECT 123}]
tcl_variable_type V
} int
set Vx [expr {1+wide(123456789123456)}]
do_test types3-2.3 {
set V [db one {SELECT 1234567890123456}]
tcl_variable_type V
} [tcl_variable_type Vx]
do_test types3-2.4.1 {
set V [db one {SELECT 1234567890123456.1}]
tcl_variable_type V
} double
do_test types3-2.4.2 {
set V [db one {SELECT 1234567890123.456}]
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
|