diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/cast.test | 184 | ||||
-rw-r--r-- | test/func.test | 130 |
2 files changed, 185 insertions, 129 deletions
diff --git a/test/cast.test b/test/cast.test new file mode 100644 index 000000000..04a36c4d3 --- /dev/null +++ b/test/cast.test @@ -0,0 +1,184 @@ +# 2001 September 15 +# +# 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 CAST operator. +# +# $Id: cast.test,v 1.1 2005/06/25 18:42:16 drh Exp $ + +set testdir [file dirname $argv0] +source $testdir/tester.tcl + +# Only run these tests if the build includes the CAST operator +ifcapable !cast { + finish_test + return +} + +# Tests for the CAST( AS blob), CAST( AS text) and CAST( AS numeric) built-ins +# +do_test cast-1.1 { + execsql {SELECT x'616263'} +} abc +do_test cast-1.2 { + execsql {SELECT typeof(x'616263')} +} blob +do_test cast-1.3 { + execsql {SELECT CAST(x'616263' AS text)} +} abc +do_test cast-1.4 { + execsql {SELECT typeof(CAST(x'616263' AS text))} +} text +do_test cast-1.5 { + execsql {SELECT CAST(x'616263' AS numeric)} +} 0.0 +do_test cast-1.6 { + execsql {SELECT typeof(CAST(x'616263' AS numeric))} +} real +do_test cast-1.7 { + execsql {SELECT CAST(x'616263' AS blob)} +} abc +do_test cast-1.8 { + execsql {SELECT typeof(CAST(x'616263' AS blob))} +} blob +do_test cast-1.9 { + execsql {SELECT CAST(x'616263' AS integer)} +} 0 +do_test cast-1.10 { + execsql {SELECT typeof(CAST(x'616263' AS integer))} +} integer +do_test cast-1.11 { + execsql {SELECT null} +} {{}} +do_test cast-1.12 { + execsql {SELECT typeof(NULL)} +} null +do_test cast-1.13 { + execsql {SELECT CAST(NULL AS text)} +} {{}} +do_test cast-1.14 { + execsql {SELECT typeof(CAST(NULL AS text))} +} null +do_test cast-1.15 { + execsql {SELECT CAST(NULL AS numeric)} +} {{}} +do_test cast-1.16 { + execsql {SELECT typeof(CAST(NULL AS numeric))} +} null +do_test cast-1.17 { + execsql {SELECT CAST(NULL AS blob)} +} {{}} +do_test cast-1.18 { + execsql {SELECT typeof(CAST(NULL AS blob))} +} null +do_test cast-1.19 { + execsql {SELECT CAST(NULL AS integer)} +} {{}} +do_test cast-1.20 { + execsql {SELECT typeof(CAST(NULL AS integer))} +} null +do_test cast-1.21 { + execsql {SELECT 123} +} {123} +do_test cast-1.22 { + execsql {SELECT typeof(123)} +} integer +do_test cast-1.23 { + execsql {SELECT CAST(123 AS text)} +} {123} +do_test cast-1.24 { + execsql {SELECT typeof(CAST(123 AS text))} +} text +do_test cast-1.25 { + execsql {SELECT CAST(123 AS numeric)} +} 123 +do_test cast-1.26 { + execsql {SELECT typeof(CAST(123 AS numeric))} +} integer +do_test cast-1.27 { + execsql {SELECT CAST(123 AS blob)} +} {123} +do_test cast-1.28 { + execsql {SELECT typeof(CAST(123 AS blob))} +} blob +do_test cast-1.29 { + execsql {SELECT CAST(123 AS integer)} +} {123} +do_test cast-1.30 { + execsql {SELECT typeof(CAST(123 AS integer))} +} integer +do_test cast-1.31 { + execsql {SELECT 123.456} +} {123.456} +do_test cast-1.32 { + execsql {SELECT typeof(123.456)} +} real +do_test cast-1.33 { + execsql {SELECT CAST(123.456 AS text)} +} {123.456} +do_test cast-1.34 { + execsql {SELECT typeof(CAST(123.456 AS text))} +} text +do_test cast-1.35 { + execsql {SELECT CAST(123.456 AS numeric)} +} 123.456 +do_test cast-1.36 { + execsql {SELECT typeof(CAST(123.456 AS numeric))} +} real +do_test cast-1.37 { + execsql {SELECT CAST(123.456 AS blob)} +} {123.456} +do_test cast-1.38 { + execsql {SELECT typeof(CAST(123.456 AS blob))} +} blob +do_test cast-1.39 { + execsql {SELECT CAST(123.456 AS integer)} +} {123} +do_test cast-1.38 { + execsql {SELECT typeof(CAST(123.456 AS integer))} +} integer +do_test cast-1.41 { + execsql {SELECT '123abc'} +} {123abc} +do_test cast-1.42 { + execsql {SELECT typeof('123abc')} +} text +do_test cast-1.43 { + execsql {SELECT CAST('123abc' AS text)} +} {123abc} +do_test cast-1.44 { + execsql {SELECT typeof(CAST('123abc' AS text))} +} text +do_test cast-1.45 { + execsql {SELECT CAST('123abc' AS numeric)} +} 123.0 +do_test cast-1.46 { + execsql {SELECT typeof(CAST('123abc' AS numeric))} +} real +do_test cast-1.47 { + execsql {SELECT CAST('123abc' AS blob)} +} {123abc} +do_test cast-1.48 { + execsql {SELECT typeof(CAST('123abc' AS blob))} +} blob +do_test cast-1.49 { + execsql {SELECT CAST('123abc' AS integer)} +} 123 +do_test cast-1.50 { + execsql {SELECT typeof(CAST('123abc' AS integer))} +} integer +do_test cast-1.51 { + execsql {SELECT CAST('123.5abc' AS numeric)} +} 123.5 +do_test cast-1.53 { + execsql {SELECT CAST('123.5abc' AS integer)} +} 123 + +finish_test diff --git a/test/func.test b/test/func.test index ab8b6f6df..d8e5c3f09 100644 --- a/test/func.test +++ b/test/func.test @@ -11,7 +11,7 @@ # This file implements regression tests for SQLite library. The # focus of this file is testing built-in functions. # -# $Id: func.test,v 1.35 2005/06/22 10:53:59 drh Exp $ +# $Id: func.test,v 1.36 2005/06/25 18:42:16 drh Exp $ set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -485,134 +485,6 @@ do_test func-16.1 { } } {X'616263' NULL} -# Tests for the blob(), text() and numeric() built-ins -# -do_test func-17.1 { - execsql {SELECT x'616263'} -} abc -do_test func-17.2 { - execsql {SELECT typeof(x'616263')} -} blob -do_test func-17.3 { - execsql {SELECT text(x'616263')} -} abc -do_test func-17.4 { - execsql {SELECT typeof(text(x'616263'))} -} text -do_test func-17.5 { - execsql {SELECT numeric(x'616263')} -} 0 -do_test func-17.6 { - execsql {SELECT typeof(numeric(x'616263'))} -} integer -do_test func-17.7 { - execsql {SELECT blob(x'616263')} -} abc -do_test func-17.8 { - execsql {SELECT typeof(blob(x'616263'))} -} blob -do_test func-17.11 { - execsql {SELECT null} -} {{}} -do_test func-17.12 { - execsql {SELECT typeof(NULL)} -} null -do_test func-17.13 { - execsql {SELECT text(NULL)} -} {{}} -do_test func-17.14 { - execsql {SELECT typeof(text(NULL))} -} text -do_test func-17.15 { - execsql {SELECT numeric(NULL)} -} 0 -do_test func-17.16 { - execsql {SELECT typeof(numeric(NULL))} -} integer -do_test func-17.17 { - execsql {SELECT blob(NULL)} -} {{}} -do_test func-17.18 { - execsql {SELECT typeof(blob(NULL))} -} blob -do_test func-17.21 { - execsql {SELECT 123} -} {123} -do_test func-17.22 { - execsql {SELECT typeof(123)} -} integer -do_test func-17.23 { - execsql {SELECT text(123)} -} {123} -do_test func-17.24 { - execsql {SELECT typeof(text(123))} -} text -do_test func-17.25 { - execsql {SELECT numeric(123)} -} 123 -do_test func-17.26 { - execsql {SELECT typeof(numeric(123))} -} integer -do_test func-17.27 { - execsql {SELECT blob(123)} -} {123} -do_test func-17.28 { - execsql {SELECT typeof(blob(123))} -} blob -do_test func-17.31 { - execsql {SELECT 123.456} -} {123.456} -do_test func-17.32 { - execsql {SELECT typeof(123.456)} -} real -do_test func-17.33 { - execsql {SELECT text(123.456)} -} {123.456} -do_test func-17.34 { - execsql {SELECT typeof(text(123.456))} -} text -do_test func-17.35 { - execsql {SELECT numeric(123.456)} -} 123.456 -do_test func-17.36 { - execsql {SELECT typeof(numeric(123.456))} -} real -do_test func-17.37 { - execsql {SELECT blob(123.456)} -} {123.456} -do_test func-17.38 { - execsql {SELECT typeof(blob(123.456))} -} blob -do_test func-17.41 { - execsql {SELECT '123abc'} -} {123abc} -do_test func-17.42 { - execsql {SELECT typeof('123abc')} -} text -do_test func-17.43 { - execsql {SELECT text('123abc')} -} {123abc} -do_test func-17.44 { - execsql {SELECT typeof(text('123abc'))} -} text -do_test func-17.45 { - execsql {SELECT numeric('123abc')} -} 123 -do_test func-17.46 { - execsql {SELECT typeof(numeric('123abc'))} -} integer -do_test func-17.47 { - execsql {SELECT blob('123abc')} -} {123abc} -do_test func-17.48 { - execsql {SELECT typeof(blob('123abc'))} -} blob -do_test func-17.49 { - execsql {SELECT numeric('123.5abc')} -} 123.5 -do_test func-17.49b { - execsql {SELECT typeof(numeric('123.5abc'))} -} real finish_test |