2013-03-11 05:23:37 +04:00
|
|
|
# 2013 March 10
|
|
|
|
#
|
|
|
|
# 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
|
2013-03-13 10:48:05 +04:00
|
|
|
# focus of this file is testing the tointeger() and toreal()
|
2013-03-11 05:23:37 +04:00
|
|
|
# functions.
|
|
|
|
#
|
|
|
|
set testdir [file dirname $argv0]
|
|
|
|
source $testdir/tester.tcl
|
|
|
|
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-1.1 {
|
2013-03-11 05:23:37 +04:00
|
|
|
SELECT tointeger(NULL);
|
|
|
|
} {{}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-1.2 {
|
2013-03-11 05:23:37 +04:00
|
|
|
SELECT tointeger('');
|
|
|
|
} {{}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-1.3 {
|
2013-03-11 05:23:37 +04:00
|
|
|
SELECT tointeger(' ');
|
|
|
|
} {{}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-1.4 {
|
2013-03-11 05:23:37 +04:00
|
|
|
SELECT tointeger('1234');
|
|
|
|
} {1234}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-1.5 {
|
2013-03-11 05:23:37 +04:00
|
|
|
SELECT tointeger(' 1234');
|
|
|
|
} {1234}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-1.6 {
|
2013-03-11 05:23:37 +04:00
|
|
|
SELECT tointeger('bad');
|
|
|
|
} {{}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-1.7 {
|
2013-03-11 05:23:37 +04:00
|
|
|
SELECT tointeger('0xBAD');
|
|
|
|
} {{}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-1.8 {
|
2013-03-11 05:23:37 +04:00
|
|
|
SELECT tointeger('123BAD');
|
|
|
|
} {{}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-1.9 {
|
2013-03-11 05:23:37 +04:00
|
|
|
SELECT tointeger('0x123BAD');
|
|
|
|
} {{}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-1.10 {
|
2013-03-11 05:23:37 +04:00
|
|
|
SELECT tointeger('123NO');
|
|
|
|
} {{}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-1.11 {
|
2013-03-11 05:23:37 +04:00
|
|
|
SELECT tointeger('0x123NO');
|
|
|
|
} {{}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-1.12 {
|
2013-03-11 05:23:37 +04:00
|
|
|
SELECT tointeger('-0x1');
|
|
|
|
} {{}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-1.13 {
|
2013-03-11 05:23:37 +04:00
|
|
|
SELECT tointeger('-0x0');
|
|
|
|
} {{}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-1.14 {
|
2013-03-11 05:23:37 +04:00
|
|
|
SELECT tointeger('0x0');
|
|
|
|
} {{}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-1.15 {
|
2013-03-11 05:23:37 +04:00
|
|
|
SELECT tointeger('0x1');
|
|
|
|
} {{}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-1.16 {
|
2013-03-11 05:23:37 +04:00
|
|
|
SELECT tointeger(-1);
|
|
|
|
} {-1}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-1.17 {
|
2013-03-11 05:23:37 +04:00
|
|
|
SELECT tointeger(-0);
|
|
|
|
} {0}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-1.18 {
|
2013-03-11 05:23:37 +04:00
|
|
|
SELECT tointeger(0);
|
|
|
|
} {0}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-1.19 {
|
2013-03-11 05:23:37 +04:00
|
|
|
SELECT tointeger(1);
|
|
|
|
} {1}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-1.20 {
|
2013-03-11 05:23:37 +04:00
|
|
|
SELECT tointeger(-1.79769313486232e308 - 1);
|
2013-03-12 13:07:25 +04:00
|
|
|
} {{}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-1.21 {
|
2013-03-11 05:23:37 +04:00
|
|
|
SELECT tointeger(-1.79769313486232e308);
|
2013-03-12 13:07:25 +04:00
|
|
|
} {{}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-1.22 {
|
2013-03-11 05:23:37 +04:00
|
|
|
SELECT tointeger(-1.79769313486232e308 + 1);
|
2013-03-12 13:07:25 +04:00
|
|
|
} {{}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-1.23 {
|
2013-03-11 05:23:37 +04:00
|
|
|
SELECT tointeger(-9223372036854775808 - 1);
|
|
|
|
} {-9223372036854775808}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-1.24 {
|
2013-03-11 05:23:37 +04:00
|
|
|
SELECT tointeger(-9223372036854775808);
|
|
|
|
} {-9223372036854775808}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-1.25 {
|
2013-03-11 05:23:37 +04:00
|
|
|
SELECT tointeger(-9223372036854775808 + 1);
|
|
|
|
} {-9223372036854775807}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-1.26 {
|
2013-03-11 05:23:37 +04:00
|
|
|
SELECT tointeger(-2147483648 - 1);
|
|
|
|
} {-2147483649}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-1.27 {
|
2013-03-11 05:23:37 +04:00
|
|
|
SELECT tointeger(-2147483648);
|
|
|
|
} {-2147483648}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-1.28 {
|
2013-03-11 05:23:37 +04:00
|
|
|
SELECT tointeger(-2147483648 + 1);
|
|
|
|
} {-2147483647}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-1.29 {
|
2013-03-11 05:23:37 +04:00
|
|
|
SELECT tointeger(2147483647 - 1);
|
|
|
|
} {2147483646}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-1.30 {
|
2013-03-11 05:23:37 +04:00
|
|
|
SELECT tointeger(2147483647);
|
|
|
|
} {2147483647}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-1.31 {
|
2013-03-11 05:23:37 +04:00
|
|
|
SELECT tointeger(2147483647 + 1);
|
|
|
|
} {2147483648}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-1.32 {
|
2013-03-11 05:23:37 +04:00
|
|
|
SELECT tointeger(9223372036854775807 - 1);
|
|
|
|
} {9223372036854775806}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-1.33 {
|
2013-03-11 05:23:37 +04:00
|
|
|
SELECT tointeger(9223372036854775807);
|
|
|
|
} {9223372036854775807}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-1.34 {
|
2013-03-11 05:23:37 +04:00
|
|
|
SELECT tointeger(9223372036854775807 + 1);
|
2013-06-21 23:29:33 +04:00
|
|
|
} {{}}
|
|
|
|
do_execsql_test func4-1.35 {
|
2013-03-11 05:23:37 +04:00
|
|
|
SELECT tointeger(1.79769313486232e308 - 1);
|
2013-03-12 13:07:25 +04:00
|
|
|
} {{}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-1.36 {
|
2013-03-11 05:23:37 +04:00
|
|
|
SELECT tointeger(1.79769313486232e308);
|
2013-03-12 13:07:25 +04:00
|
|
|
} {{}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-1.37 {
|
2013-03-11 05:23:37 +04:00
|
|
|
SELECT tointeger(1.79769313486232e308 + 1);
|
2013-03-12 13:07:25 +04:00
|
|
|
} {{}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-1.38 {
|
2013-03-11 05:23:37 +04:00
|
|
|
SELECT tointeger(4503599627370496 - 1);
|
|
|
|
} {4503599627370495}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-1.39 {
|
2013-03-11 05:23:37 +04:00
|
|
|
SELECT tointeger(4503599627370496);
|
|
|
|
} {4503599627370496}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-1.40 {
|
2013-03-11 05:23:37 +04:00
|
|
|
SELECT tointeger(4503599627370496 + 1);
|
|
|
|
} {4503599627370497}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-1.41 {
|
2013-03-11 05:23:37 +04:00
|
|
|
SELECT tointeger(9007199254740992 - 1);
|
|
|
|
} {9007199254740991}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-1.42 {
|
2013-03-11 05:23:37 +04:00
|
|
|
SELECT tointeger(9007199254740992);
|
|
|
|
} {9007199254740992}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-1.43 {
|
2013-03-11 05:23:37 +04:00
|
|
|
SELECT tointeger(9007199254740992 + 1);
|
|
|
|
} {9007199254740993}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-1.44 {
|
2013-03-11 05:23:37 +04:00
|
|
|
SELECT tointeger(9223372036854775808 - 1);
|
2013-06-21 23:29:33 +04:00
|
|
|
} {{}}
|
|
|
|
do_execsql_test func4-1.45 {
|
2013-03-11 05:23:37 +04:00
|
|
|
SELECT tointeger(9223372036854775808);
|
2013-06-21 23:29:33 +04:00
|
|
|
} {{}}
|
|
|
|
do_execsql_test func4-1.46 {
|
2013-03-11 05:23:37 +04:00
|
|
|
SELECT tointeger(9223372036854775808 + 1);
|
2013-06-21 23:29:33 +04:00
|
|
|
} {{}}
|
|
|
|
do_execsql_test func4-1.47 {
|
2013-03-11 05:23:37 +04:00
|
|
|
SELECT tointeger(18446744073709551616 - 1);
|
2013-03-12 13:07:25 +04:00
|
|
|
} {{}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-1.48 {
|
2013-03-11 05:23:37 +04:00
|
|
|
SELECT tointeger(18446744073709551616);
|
2013-03-12 13:07:25 +04:00
|
|
|
} {{}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-1.49 {
|
2013-03-11 05:23:37 +04:00
|
|
|
SELECT tointeger(18446744073709551616 + 1);
|
2013-03-12 13:07:25 +04:00
|
|
|
} {{}}
|
2013-03-11 05:23:37 +04:00
|
|
|
|
|
|
|
ifcapable floatingpoint {
|
|
|
|
set i 0
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-2.1 {
|
2013-03-13 10:48:05 +04:00
|
|
|
SELECT toreal(NULL);
|
2013-03-11 05:23:37 +04:00
|
|
|
} {{}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-2.2 {
|
2013-03-13 10:48:05 +04:00
|
|
|
SELECT toreal('');
|
2013-03-11 05:23:37 +04:00
|
|
|
} {{}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-2.3 {
|
2013-03-13 10:48:05 +04:00
|
|
|
SELECT toreal(' ');
|
2013-03-11 05:23:37 +04:00
|
|
|
} {{}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-2.4 {
|
2013-03-13 10:48:05 +04:00
|
|
|
SELECT toreal('1234');
|
2013-03-11 05:23:37 +04:00
|
|
|
} {1234.0}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-2.5 {
|
2013-03-13 10:48:05 +04:00
|
|
|
SELECT toreal(' 1234');
|
2013-03-11 05:23:37 +04:00
|
|
|
} {1234.0}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-2.6 {
|
2013-03-13 10:48:05 +04:00
|
|
|
SELECT toreal('bad');
|
2013-03-11 05:23:37 +04:00
|
|
|
} {{}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-2.7 {
|
2013-03-13 10:48:05 +04:00
|
|
|
SELECT toreal('0xBAD');
|
2013-03-11 05:23:37 +04:00
|
|
|
} {{}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-2.8 {
|
2013-03-13 10:48:05 +04:00
|
|
|
SELECT toreal('123BAD');
|
2013-03-11 05:23:37 +04:00
|
|
|
} {{}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-2.9 {
|
2013-03-13 10:48:05 +04:00
|
|
|
SELECT toreal('0x123BAD');
|
2013-03-11 05:23:37 +04:00
|
|
|
} {{}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-2.10 {
|
2013-03-13 10:48:05 +04:00
|
|
|
SELECT toreal('123NO');
|
2013-03-11 05:23:37 +04:00
|
|
|
} {{}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-2.11 {
|
2013-03-13 10:48:05 +04:00
|
|
|
SELECT toreal('0x123NO');
|
2013-03-11 05:23:37 +04:00
|
|
|
} {{}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-2.12 {
|
2013-03-13 10:48:05 +04:00
|
|
|
SELECT toreal('-0x1');
|
2013-03-11 05:23:37 +04:00
|
|
|
} {{}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-2.13 {
|
2013-03-13 10:48:05 +04:00
|
|
|
SELECT toreal('-0x0');
|
2013-03-11 05:23:37 +04:00
|
|
|
} {{}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-2.14 {
|
2013-03-13 10:48:05 +04:00
|
|
|
SELECT toreal('0x0');
|
2013-03-11 05:23:37 +04:00
|
|
|
} {{}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-2.15 {
|
2013-03-13 10:48:05 +04:00
|
|
|
SELECT toreal('0x1');
|
2013-03-11 05:23:37 +04:00
|
|
|
} {{}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-2.16 {
|
2013-03-13 10:48:05 +04:00
|
|
|
SELECT toreal(-1);
|
2013-03-11 05:23:37 +04:00
|
|
|
} {-1.0}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-2.17 {
|
2013-03-13 10:48:05 +04:00
|
|
|
SELECT toreal(-0);
|
2013-03-11 05:23:37 +04:00
|
|
|
} {0.0}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-2.18 {
|
2013-03-13 10:48:05 +04:00
|
|
|
SELECT toreal(0);
|
2013-03-11 05:23:37 +04:00
|
|
|
} {0.0}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-2.19 {
|
2013-03-13 10:48:05 +04:00
|
|
|
SELECT toreal(1);
|
2013-03-11 05:23:37 +04:00
|
|
|
} {1.0}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-2.20 {
|
2013-03-13 10:48:05 +04:00
|
|
|
SELECT toreal(-1.79769313486232e308 - 1);
|
2013-03-11 05:23:37 +04:00
|
|
|
} {-Inf}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-2.21 {
|
2013-03-13 10:48:05 +04:00
|
|
|
SELECT toreal(-1.79769313486232e308);
|
2013-03-11 05:23:37 +04:00
|
|
|
} {-Inf}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-2.22 {
|
2013-03-13 10:48:05 +04:00
|
|
|
SELECT toreal(-1.79769313486232e308 + 1);
|
2013-03-11 05:23:37 +04:00
|
|
|
} {-Inf}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-2.23 {
|
2013-03-13 10:48:05 +04:00
|
|
|
SELECT toreal(-9223372036854775808 - 1);
|
2013-03-11 05:23:37 +04:00
|
|
|
} {-9.22337203685478e+18}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-2.24 {
|
2013-03-13 10:48:05 +04:00
|
|
|
SELECT toreal(-9223372036854775808);
|
2013-03-11 05:23:37 +04:00
|
|
|
} {-9.22337203685478e+18}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-2.25 {
|
2013-03-13 10:48:05 +04:00
|
|
|
SELECT toreal(-9223372036854775808 + 1);
|
2013-03-11 05:23:37 +04:00
|
|
|
} {-9.22337203685478e+18}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-2.26 {
|
2013-03-13 10:48:05 +04:00
|
|
|
SELECT toreal(-2147483648 - 1);
|
2013-03-11 05:23:37 +04:00
|
|
|
} {-2147483649.0}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-2.27 {
|
2013-03-13 10:48:05 +04:00
|
|
|
SELECT toreal(-2147483648);
|
2013-03-11 05:23:37 +04:00
|
|
|
} {-2147483648.0}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-2.28 {
|
2013-03-13 10:48:05 +04:00
|
|
|
SELECT toreal(-2147483648 + 1);
|
2013-03-11 05:23:37 +04:00
|
|
|
} {-2147483647.0}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-2.29 {
|
2013-03-13 10:48:05 +04:00
|
|
|
SELECT toreal(2147483647 - 1);
|
2013-03-11 05:23:37 +04:00
|
|
|
} {2147483646.0}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-2.30 {
|
2013-03-13 10:48:05 +04:00
|
|
|
SELECT toreal(2147483647);
|
2013-03-11 05:23:37 +04:00
|
|
|
} {2147483647.0}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-2.31 {
|
2013-03-13 10:48:05 +04:00
|
|
|
SELECT toreal(2147483647 + 1);
|
2013-03-11 05:23:37 +04:00
|
|
|
} {2147483648.0}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-2.32 {
|
2013-03-13 10:48:05 +04:00
|
|
|
SELECT toreal(9223372036854775807 - 1);
|
2013-03-11 05:23:37 +04:00
|
|
|
} {9.22337203685478e+18}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-2.33 {
|
2013-03-13 10:48:05 +04:00
|
|
|
SELECT toreal(9223372036854775807);
|
2013-03-11 05:23:37 +04:00
|
|
|
} {9.22337203685478e+18}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-2.34 {
|
2013-03-13 10:48:05 +04:00
|
|
|
SELECT toreal(9223372036854775807 + 1);
|
2013-03-11 05:23:37 +04:00
|
|
|
} {9.22337203685478e+18}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-2.35 {
|
2013-03-13 10:48:05 +04:00
|
|
|
SELECT toreal(1.79769313486232e308 - 1);
|
2013-03-11 05:23:37 +04:00
|
|
|
} {Inf}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-2.36 {
|
2013-03-13 10:48:05 +04:00
|
|
|
SELECT toreal(1.79769313486232e308);
|
2013-03-11 05:23:37 +04:00
|
|
|
} {Inf}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-2.37 {
|
2013-03-13 10:48:05 +04:00
|
|
|
SELECT toreal(1.79769313486232e308 + 1);
|
2013-03-11 05:23:37 +04:00
|
|
|
} {Inf}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-2.38 {
|
2013-03-13 10:48:05 +04:00
|
|
|
SELECT toreal(4503599627370496 - 1);
|
2013-03-11 05:23:37 +04:00
|
|
|
} {4503599627370500.0}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-2.39 {
|
2013-03-13 10:48:05 +04:00
|
|
|
SELECT toreal(4503599627370496);
|
2013-03-11 05:23:37 +04:00
|
|
|
} {4503599627370500.0}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-2.40 {
|
2013-03-13 10:48:05 +04:00
|
|
|
SELECT toreal(4503599627370496 + 1);
|
2013-03-11 05:23:37 +04:00
|
|
|
} {4503599627370500.0}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-2.41 {
|
2013-03-13 10:48:05 +04:00
|
|
|
SELECT toreal(9007199254740992 - 1);
|
2013-03-11 05:23:37 +04:00
|
|
|
} {9007199254740990.0}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-2.42 {
|
2013-03-13 10:48:05 +04:00
|
|
|
SELECT toreal(9007199254740992);
|
2013-03-11 05:23:37 +04:00
|
|
|
} {9007199254740990.0}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-2.43 {
|
2013-03-13 10:48:05 +04:00
|
|
|
SELECT toreal(9007199254740992 + 1);
|
2013-03-11 05:23:37 +04:00
|
|
|
} {9007199254740990.0}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-2.44 {
|
2013-03-13 10:48:05 +04:00
|
|
|
SELECT toreal(9223372036854775808 - 1);
|
2013-03-11 05:23:37 +04:00
|
|
|
} {9.22337203685478e+18}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-2.45 {
|
2013-03-13 10:48:05 +04:00
|
|
|
SELECT toreal(9223372036854775808);
|
2013-03-11 05:23:37 +04:00
|
|
|
} {9.22337203685478e+18}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-2.46 {
|
2013-03-13 10:48:05 +04:00
|
|
|
SELECT toreal(9223372036854775808 + 1);
|
2013-03-11 05:23:37 +04:00
|
|
|
} {9.22337203685478e+18}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-2.47 {
|
2013-03-13 10:48:05 +04:00
|
|
|
SELECT toreal(18446744073709551616 - 1);
|
2013-03-11 05:23:37 +04:00
|
|
|
} {1.84467440737096e+19}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-2.48 {
|
2013-03-13 10:48:05 +04:00
|
|
|
SELECT toreal(18446744073709551616);
|
2013-03-11 05:23:37 +04:00
|
|
|
} {1.84467440737096e+19}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-2.49 {
|
2013-03-13 10:48:05 +04:00
|
|
|
SELECT toreal(18446744073709551616 + 1);
|
2013-03-11 05:23:37 +04:00
|
|
|
} {1.84467440737096e+19}
|
|
|
|
}
|
|
|
|
|
2013-03-11 10:24:46 +04:00
|
|
|
ifcapable check {
|
|
|
|
set i 0
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-3.1 {
|
2013-03-11 10:24:46 +04:00
|
|
|
CREATE TABLE t1(
|
|
|
|
x INTEGER CHECK(tointeger(x) IS NOT NULL AND x = CAST(x AS INTEGER))
|
|
|
|
);
|
|
|
|
} {}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_test func4-3.2 {
|
2013-03-11 10:24:46 +04:00
|
|
|
catchsql {
|
|
|
|
INSERT INTO t1 (x) VALUES (NULL);
|
|
|
|
}
|
|
|
|
} {1 {constraint failed}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_test func4-3.3 {
|
2013-03-11 10:24:46 +04:00
|
|
|
catchsql {
|
|
|
|
INSERT INTO t1 (x) VALUES (NULL);
|
|
|
|
}
|
|
|
|
} {1 {constraint failed}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_test func4-3.4 {
|
2013-03-11 10:24:46 +04:00
|
|
|
catchsql {
|
|
|
|
INSERT INTO t1 (x) VALUES ('');
|
|
|
|
}
|
|
|
|
} {1 {constraint failed}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_test func4-3.5 {
|
2013-03-11 10:24:46 +04:00
|
|
|
catchsql {
|
|
|
|
INSERT INTO t1 (x) VALUES ('bad');
|
|
|
|
}
|
|
|
|
} {1 {constraint failed}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_test func4-3.6 {
|
2013-03-11 10:24:46 +04:00
|
|
|
catchsql {
|
|
|
|
INSERT INTO t1 (x) VALUES ('1234bad');
|
|
|
|
}
|
|
|
|
} {1 {constraint failed}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_test func4-3.7 {
|
2013-03-12 13:07:25 +04:00
|
|
|
catchsql {
|
|
|
|
INSERT INTO t1 (x) VALUES ('1234.56bad');
|
|
|
|
}
|
|
|
|
} {1 {constraint failed}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_test func4-3.8 {
|
2013-03-11 10:24:46 +04:00
|
|
|
catchsql {
|
|
|
|
INSERT INTO t1 (x) VALUES (1234);
|
|
|
|
}
|
|
|
|
} {0 {}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_test func4-3.9 {
|
2013-03-11 10:24:46 +04:00
|
|
|
catchsql {
|
|
|
|
INSERT INTO t1 (x) VALUES (1234.56);
|
|
|
|
}
|
|
|
|
} {1 {constraint failed}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_test func4-3.10 {
|
2013-03-11 10:24:46 +04:00
|
|
|
catchsql {
|
|
|
|
INSERT INTO t1 (x) VALUES ('1234');
|
|
|
|
}
|
|
|
|
} {0 {}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_test func4-3.11 {
|
2013-03-11 10:24:46 +04:00
|
|
|
catchsql {
|
|
|
|
INSERT INTO t1 (x) VALUES ('1234.56');
|
|
|
|
}
|
|
|
|
} {1 {constraint failed}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_test func4-3.12 {
|
2013-03-11 10:24:46 +04:00
|
|
|
catchsql {
|
|
|
|
INSERT INTO t1 (x) VALUES (ZEROBLOB(4));
|
|
|
|
}
|
|
|
|
} {1 {constraint failed}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_test func4-3.13 {
|
2013-03-11 10:24:46 +04:00
|
|
|
catchsql {
|
|
|
|
INSERT INTO t1 (x) VALUES (X'');
|
|
|
|
}
|
|
|
|
} {1 {constraint failed}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_test func4-3.14 {
|
2013-03-11 10:24:46 +04:00
|
|
|
catchsql {
|
|
|
|
INSERT INTO t1 (x) VALUES (X'1234');
|
|
|
|
}
|
|
|
|
} {1 {constraint failed}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_test func4-3.15 {
|
2013-03-11 10:24:46 +04:00
|
|
|
catchsql {
|
|
|
|
INSERT INTO t1 (x) VALUES (X'12345678');
|
|
|
|
}
|
|
|
|
} {1 {constraint failed}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-3.16 {
|
2013-03-11 10:24:46 +04:00
|
|
|
SELECT x FROM t1 ORDER BY x;
|
|
|
|
} {1234 1234}
|
2013-03-12 13:07:25 +04:00
|
|
|
|
|
|
|
ifcapable floatingpoint {
|
|
|
|
set i 0
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-4.1 {
|
2013-03-12 13:07:25 +04:00
|
|
|
CREATE TABLE t2(
|
2013-03-13 10:48:05 +04:00
|
|
|
x REAL CHECK(toreal(x) IS NOT NULL)
|
2013-03-12 13:07:25 +04:00
|
|
|
);
|
|
|
|
} {}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_test func4-4.2 {
|
2013-03-12 13:07:25 +04:00
|
|
|
catchsql {
|
|
|
|
INSERT INTO t2 (x) VALUES (NULL);
|
|
|
|
}
|
|
|
|
} {1 {constraint failed}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_test func4-4.3 {
|
2013-03-12 13:07:25 +04:00
|
|
|
catchsql {
|
|
|
|
INSERT INTO t2 (x) VALUES (NULL);
|
|
|
|
}
|
|
|
|
} {1 {constraint failed}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_test func4-4.4 {
|
2013-03-12 13:07:25 +04:00
|
|
|
catchsql {
|
|
|
|
INSERT INTO t2 (x) VALUES ('');
|
|
|
|
}
|
|
|
|
} {1 {constraint failed}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_test func4-4.5 {
|
2013-03-12 13:07:25 +04:00
|
|
|
catchsql {
|
|
|
|
INSERT INTO t2 (x) VALUES ('bad');
|
|
|
|
}
|
|
|
|
} {1 {constraint failed}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_test func4-4.6 {
|
2013-03-12 13:07:25 +04:00
|
|
|
catchsql {
|
|
|
|
INSERT INTO t2 (x) VALUES ('1234bad');
|
|
|
|
}
|
|
|
|
} {1 {constraint failed}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_test func4-4.7 {
|
2013-03-12 13:07:25 +04:00
|
|
|
catchsql {
|
|
|
|
INSERT INTO t2 (x) VALUES ('1234.56bad');
|
|
|
|
}
|
|
|
|
} {1 {constraint failed}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_test func4-4.8 {
|
2013-03-12 13:07:25 +04:00
|
|
|
catchsql {
|
|
|
|
INSERT INTO t2 (x) VALUES (1234);
|
|
|
|
}
|
|
|
|
} {0 {}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_test func4-4.9 {
|
2013-03-12 13:07:25 +04:00
|
|
|
catchsql {
|
|
|
|
INSERT INTO t2 (x) VALUES (1234.56);
|
|
|
|
}
|
|
|
|
} {0 {}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_test func4-4.10 {
|
2013-03-12 13:07:25 +04:00
|
|
|
catchsql {
|
|
|
|
INSERT INTO t2 (x) VALUES ('1234');
|
|
|
|
}
|
|
|
|
} {0 {}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_test func4-4.11 {
|
2013-03-12 13:07:25 +04:00
|
|
|
catchsql {
|
|
|
|
INSERT INTO t2 (x) VALUES ('1234.56');
|
|
|
|
}
|
|
|
|
} {0 {}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_test func4-4.12 {
|
2013-03-12 13:07:25 +04:00
|
|
|
catchsql {
|
|
|
|
INSERT INTO t2 (x) VALUES (ZEROBLOB(4));
|
|
|
|
}
|
|
|
|
} {1 {constraint failed}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_test func4-4.13 {
|
2013-03-12 13:07:25 +04:00
|
|
|
catchsql {
|
|
|
|
INSERT INTO t2 (x) VALUES (X'');
|
|
|
|
}
|
|
|
|
} {1 {constraint failed}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_test func4-4.14 {
|
2013-03-12 13:07:25 +04:00
|
|
|
catchsql {
|
|
|
|
INSERT INTO t2 (x) VALUES (X'1234');
|
|
|
|
}
|
|
|
|
} {1 {constraint failed}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_test func4-4.15 {
|
2013-03-12 13:07:25 +04:00
|
|
|
catchsql {
|
|
|
|
INSERT INTO t2 (x) VALUES (X'12345678');
|
|
|
|
}
|
|
|
|
} {1 {constraint failed}}
|
2013-06-21 23:29:33 +04:00
|
|
|
do_execsql_test func4-4.16 {
|
2013-03-12 13:07:25 +04:00
|
|
|
SELECT x FROM t2 ORDER BY x;
|
|
|
|
} {1234.0 1234.0 1234.56 1234.56}
|
|
|
|
}
|
2013-03-11 10:24:46 +04:00
|
|
|
}
|
|
|
|
|
2013-03-11 05:23:37 +04:00
|
|
|
finish_test
|