1df81a8b50
FossilOrigin-Name: 51452d20f99ecbe0fdb73cfafde5270711aeacad
155 lines
4.0 KiB
Plaintext
155 lines
4.0 KiB
Plaintext
#
|
|
# 2008 January 20
|
|
#
|
|
# 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 script is the built-in RTRIM collating
|
|
# API.
|
|
#
|
|
# $Id: collateA.test,v 1.2 2008/01/21 16:47:16 drh Exp $
|
|
|
|
set testdir [file dirname $argv0]
|
|
source $testdir/tester.tcl
|
|
|
|
do_test collateA-1.1 {
|
|
execsql {
|
|
CREATE TABLE t1(
|
|
a INTEGER PRIMARY KEY,
|
|
b TEXT COLLATE BINARY,
|
|
c TEXT COLLATE RTRIM
|
|
);
|
|
INSERT INTO t1 VALUES(1, 'hello','hello');
|
|
INSERT INTO t1 VALUES(2, 'xyzzy ','xyzzy ');
|
|
INSERT INTO t1 VALUES(3, 'xyzzy ','xyzzy ');
|
|
INSERT INTO t1 VALUES(4, 'xyzzy ','xyzzy ');
|
|
SELECT count(*) FROM t1;
|
|
}
|
|
} {4}
|
|
do_test collateA-1.2 {
|
|
execsql {SELECT a FROM t1 WHERE b='hello '}
|
|
} {}
|
|
do_test collateA-1.3 {
|
|
execsql {SELECT a FROM t1 WHERE c='hello '}
|
|
} {1}
|
|
do_test collateA-1.4 {
|
|
execsql {SELECT a FROM t1 WHERE b='xyzzy'}
|
|
} {}
|
|
do_test collateA-1.5 {
|
|
execsql {SELECT a FROM t1 WHERE c='xyzzy'}
|
|
} {2 3 4}
|
|
do_test collateA-1.6 {
|
|
execsql {SELECT a FROM t1 WHERE c='xyzzy '}
|
|
} {2 3 4}
|
|
do_test collateA-1.7 {
|
|
execsql {SELECT a FROM t1 WHERE c='xyzzy '}
|
|
} {2 3 4}
|
|
do_test collateA-1.8 {
|
|
execsql {SELECT a FROM t1 WHERE c='xyzzy '}
|
|
} {2 3 4}
|
|
do_test collateA-1.9 {
|
|
execsql {SELECT a FROM t1 WHERE c='xyzzy '}
|
|
} {2 3 4}
|
|
do_test collateA-1.10 {
|
|
execsql {SELECT a FROM t1 WHERE c='xyzzy '}
|
|
} {2 3 4}
|
|
do_test collateA-1.11 {
|
|
execsql {SELECT 'abc123'='abc123 ' COLLATE RTRIM;}
|
|
} {1}
|
|
do_test collateA-1.12 {
|
|
execsql {SELECT 'abc123 '='abc123' COLLATE RTRIM;}
|
|
} {1}
|
|
do_test collateA-1.13 {
|
|
execsql {SELECT ' '='' COLLATE RTRIM, ' '='' COLLATE BINARY, ' '=''}
|
|
} {1 0 0}
|
|
do_test collateA-1.14 {
|
|
execsql {SELECT ''=' ' COLLATE RTRIM, ''=' ' COLLATE BINARY, ''=' '}
|
|
} {1 0 0}
|
|
do_test collateA-1.15 {
|
|
execsql {SELECT ' '=' ' COLLATE RTRIM, ' '=' '}
|
|
} {1 0}
|
|
do_test collateA-1.16 {
|
|
execsql {SELECT ''<>' ' COLLATE RTRIM, ''<>' ' COLLATE BINARY, ''<>' '}
|
|
} {0 1 1}
|
|
|
|
|
|
do_test collateA-2.1 {
|
|
execsql {
|
|
CREATE INDEX i1b ON t1(b);
|
|
CREATE INDEX i1c ON t1(c);
|
|
PRAGMA integrity_check;
|
|
}
|
|
} {ok}
|
|
do_test collateA-2.2 {
|
|
execsql {SELECT a FROM t1 WHERE b='hello '}
|
|
} {}
|
|
do_test collateA-2.3 {
|
|
execsql {SELECT a FROM t1 WHERE c='hello '}
|
|
} {1}
|
|
do_test collateA-2.4 {
|
|
execsql {SELECT a FROM t1 WHERE b='xyzzy'}
|
|
} {}
|
|
do_test collateA-2.5 {
|
|
execsql {SELECT a FROM t1 WHERE c='xyzzy'}
|
|
} {2 3 4}
|
|
do_test collateA-2.6 {
|
|
execsql {SELECT a FROM t1 WHERE c='xyzzy '}
|
|
} {2 3 4}
|
|
do_test collateA-2.7 {
|
|
execsql {SELECT a FROM t1 WHERE c='xyzzy '}
|
|
} {2 3 4}
|
|
do_test collateA-2.8 {
|
|
execsql {SELECT a FROM t1 WHERE c='xyzzy '}
|
|
} {2 3 4}
|
|
do_test collateA-2.9 {
|
|
execsql {SELECT a FROM t1 WHERE c='xyzzy '}
|
|
} {2 3 4}
|
|
do_test collateA-2.10 {
|
|
execsql {SELECT a FROM t1 WHERE c='xyzzy '}
|
|
} {2 3 4}
|
|
|
|
do_test collateA-3.1 {
|
|
db close
|
|
sqlite3 db test.db
|
|
execsql {
|
|
REINDEX;
|
|
PRAGMA integrity_check;
|
|
}
|
|
} {ok}
|
|
do_test collateA-3.2 {
|
|
execsql {SELECT a FROM t1 WHERE b='hello '}
|
|
} {}
|
|
do_test collateA-3.3 {
|
|
execsql {SELECT a FROM t1 WHERE c='hello '}
|
|
} {1}
|
|
do_test collateA-3.4 {
|
|
execsql {SELECT a FROM t1 WHERE b='xyzzy'}
|
|
} {}
|
|
do_test collateA-3.5 {
|
|
execsql {SELECT a FROM t1 WHERE c='xyzzy'}
|
|
} {2 3 4}
|
|
do_test collateA-3.6 {
|
|
execsql {SELECT a FROM t1 WHERE c='xyzzy '}
|
|
} {2 3 4}
|
|
do_test collateA-3.7 {
|
|
execsql {SELECT a FROM t1 WHERE c='xyzzy '}
|
|
} {2 3 4}
|
|
do_test collateA-3.8 {
|
|
execsql {SELECT a FROM t1 WHERE c='xyzzy '}
|
|
} {2 3 4}
|
|
do_test collateA-3.9 {
|
|
execsql {SELECT a FROM t1 WHERE c='xyzzy '}
|
|
} {2 3 4}
|
|
do_test collateA-3.10 {
|
|
execsql {SELECT a FROM t1 WHERE c='xyzzy '}
|
|
} {2 3 4}
|
|
|
|
|
|
finish_test
|