3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
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.
10 #***********************************************************************
11 # This file implements regression tests for SQLite library.
12 # This particular file does testing of casting strings into numeric
16 set testdir [file dirname $argv0]
17 source $testdir/tester.tcl
19 foreach enc {utf8 utf16le utf16be} {
20 do_test numcast-$enc.0 {
23 db eval "PRAGMA encoding='$enc'"
24 set x [db eval {PRAGMA encoding}]
25 string map {- {}} [string tolower $x]
27 foreach {idx str rval ival} {
28 1 12345.0 12345.0 12345
29 2 12345.0e0 12345.0 12345
30 3 -12345.0e0 -12345.0 -12345
31 4 -12345.25 -12345.25 -12345
32 5 { -12345.0} -12345.0 -12345
37 do_test numcast-$enc.$idx.1 {
38 db eval {SELECT CAST($str AS real)}
40 do_test numcast-$enc.$idx.2 {
41 db eval {SELECT CAST($str AS integer)}