mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-30 19:03:16 +03:00
Make the distinction between text and numeric data. (CVS 710)
FossilOrigin-Name: 310ac4fbaf0ed63f98bfacb55259960be03b0c8b
This commit is contained in:
@ -11,7 +11,7 @@
|
||||
# This file implements regression tests for SQLite library. The
|
||||
# focus of this file is testing the CREATE TABLE statement.
|
||||
#
|
||||
# $Id: sort.test,v 1.4 2002/01/22 14:11:30 drh Exp $
|
||||
# $Id: sort.test,v 1.5 2002/08/13 23:02:58 drh Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
@ -101,25 +101,36 @@ do_test sort-1.11 {
|
||||
# These tests are designed to reach some hard-to-reach places
|
||||
# inside the string comparison routines.
|
||||
#
|
||||
do_test sort-2.1 {
|
||||
# (Later) The sorting behavior changed in 2.7.0. But we will
|
||||
# keep these tests. You can never have too many test cases!
|
||||
#
|
||||
do_test sort-2.1.1 {
|
||||
execsql {
|
||||
UPDATE t1 SET v='x' || -flt;
|
||||
UPDATE t1 SET v='x-2b' where v=='x-0.123';
|
||||
SELECT v FROM t1 ORDER BY v;
|
||||
}
|
||||
} {x-2b x-2.15 x-3.141592653 x-123 x-4221 x0.0013442 x1.6 x11}
|
||||
do_test sort-2.2 {
|
||||
} {x-123 x-2.15 x-2b x-3.141592653 x-4221 x0.0013442 x1.6 x11}
|
||||
do_test sort-2.1.2 {
|
||||
execsql {
|
||||
UPDATE t1 SET v='x-2_' where v=='x0.0013442';
|
||||
SELECT v FROM t1 ORDER BY v;
|
||||
SELECT v FROM t1 ORDER BY substr(v,2,999);
|
||||
}
|
||||
} {x-2_ x-2b x-2.15 x-3.141592653 x-123 x-4221 x1.6 x11}
|
||||
do_test sort-2.3 {
|
||||
} {x-123 x-2.15 x-2b x-3.141592653 x-4221 x0.0013442 x1.6 x11}
|
||||
do_test sort-2.1.3 {
|
||||
execsql {
|
||||
UPDATE t1 SET v='x ' || (-1.3+0.01*n);
|
||||
SELECT v FROM t1 ORDER BY v;
|
||||
SELECT v FROM t1 ORDER BY substr(v,2,999)+0.0;
|
||||
}
|
||||
} {{x -1.29} {x -1.28} {x -1.27} {x -1.26} {x -1.25} {x -1.24} {x -1.23} {x -1.22}}
|
||||
} {x-4221 x-123 x-3.141592653 x-2.15 x-2b x0.0013442 x1.6 x11}
|
||||
do_test sort-2.1.4 {
|
||||
execsql {
|
||||
SELECT v FROM t1 ORDER BY substr(v,2,999) DESC;
|
||||
}
|
||||
} {x11 x1.6 x0.0013442 x-4221 x-3.141592653 x-2b x-2.15 x-123}
|
||||
do_test sort-2.1.5 {
|
||||
execsql {
|
||||
SELECT v FROM t1 ORDER BY substr(v,2,999)+0.0 DESC;
|
||||
}
|
||||
} {x11 x1.6 x0.0013442 x-2b x-2.15 x-3.141592653 x-123 x-4221}
|
||||
|
||||
# This is a bug fix for 2.2.4.
|
||||
# Strings are normally mapped to upper-case for a caseless comparison.
|
||||
@ -154,5 +165,58 @@ do_test sort-3.4 {
|
||||
}
|
||||
} {agna 3 aglientu 1 aglie` 2}
|
||||
|
||||
# Version 2.7.0 testing.
|
||||
#
|
||||
do_test sort-4.1 {
|
||||
execsql {
|
||||
INSERT INTO t1 VALUES(9,'x2.7',3,'IX',4.0e5);
|
||||
INSERT INTO t1 VALUES(10,'x5.0e10',3,'X',-4.0e5);
|
||||
INSERT INTO t1 VALUES(11,'x-4.0e9',3,'XI',4.1e4);
|
||||
INSERT INTO t1 VALUES(12,'x01234567890123456789',3,'XII',-4.2e3);
|
||||
SELECT n FROM t1 ORDER BY n;
|
||||
}
|
||||
} {1 2 3 4 5 6 7 8 9 10 11 12}
|
||||
do_test sort-4.2 {
|
||||
execsql {
|
||||
SELECT n||'' FROM t1 ORDER BY 1;
|
||||
}
|
||||
} {1 10 11 12 2 3 4 5 6 7 8 9}
|
||||
do_test sort-4.3 {
|
||||
execsql {
|
||||
SELECT n+0 FROM t1 ORDER BY 1;
|
||||
}
|
||||
} {1 2 3 4 5 6 7 8 9 10 11 12}
|
||||
do_test sort-4.4 {
|
||||
execsql {
|
||||
SELECT n||'' FROM t1 ORDER BY 1 DESC;
|
||||
}
|
||||
} {9 8 7 6 5 4 3 2 12 11 10 1}
|
||||
do_test sort-4.5 {
|
||||
execsql {
|
||||
SELECT n+0 FROM t1 ORDER BY 1 DESC;
|
||||
}
|
||||
} {12 11 10 9 8 7 6 5 4 3 2 1}
|
||||
do_test sort-4.6 {
|
||||
execsql {
|
||||
SELECT v FROM t1 ORDER BY 1;
|
||||
}
|
||||
} {x-123 x-2.15 x-2b x-3.141592653 x-4.0e9 x-4221 x0.0013442 x01234567890123456789 x1.6 x11 x2.7 x5.0e10}
|
||||
do_test sort-4.7 {
|
||||
execsql {
|
||||
SELECT v FROM t1 ORDER BY 1 DESC;
|
||||
}
|
||||
} {x5.0e10 x2.7 x11 x1.6 x01234567890123456789 x0.0013442 x-4221 x-4.0e9 x-3.141592653 x-2b x-2.15 x-123}
|
||||
do_test sort-4.8 {
|
||||
execsql {
|
||||
SELECT substr(v,2,99) FROM t1 ORDER BY 1;
|
||||
}
|
||||
} {-123 -2.15 -2b -3.141592653 -4.0e9 -4221 0.0013442 01234567890123456789 1.6 11 2.7 5.0e10}
|
||||
do_test sort-4.9 {
|
||||
execsql {
|
||||
SELECT substr(v,2,99)+0.0 FROM t1 ORDER BY 1;
|
||||
}
|
||||
} {-4000000000 -4221 -123 -3.141592653 -2.15 -2 0.0013442 1.6 2.7 11 50000000000 1.23456789012346e+18}
|
||||
|
||||
|
||||
|
||||
finish_test
|
||||
|
Reference in New Issue
Block a user