1# 2# 2008 January 20 3# 4# The author disclaims copyright to this source code. In place of 5# a legal notice, here is a blessing: 6# 7# May you do good and not evil. 8# May you find forgiveness for yourself and forgive others. 9# May you share freely, never taking more than you give. 10# 11#*********************************************************************** 12# This file implements regression tests for SQLite library. The 13# focus of this script is the built-in RTRIM collating 14# API. 15# 16# $Id: collateA.test,v 1.3 2008/04/15 04:02:41 drh Exp $ 17 18set testdir [file dirname $argv0] 19source $testdir/tester.tcl 20 21do_test collateA-1.1 { 22 execsql { 23 CREATE TABLE t1( 24 a INTEGER PRIMARY KEY, 25 b TEXT COLLATE BINARY, 26 c TEXT COLLATE RTRIM 27 ); 28 INSERT INTO t1 VALUES(1, 'abcde','abcde'); 29 INSERT INTO t1 VALUES(2, 'xyzzy ','xyzzy '); 30 INSERT INTO t1 VALUES(3, 'xyzzy ','xyzzy '); 31 INSERT INTO t1 VALUES(4, 'xyzzy ','xyzzy '); 32 INSERT INTO t1 VALUES(5, ' ', ' '); 33 INSERT INTO t1 VALUES(6, '', ''); 34 SELECT count(*) FROM t1; 35 } 36} {6} 37do_test collateA-1.2 { 38 execsql {SELECT a FROM t1 WHERE b='abcde '} 39} {} 40do_test collateA-1.3 { 41 execsql {SELECT a FROM t1 WHERE c='abcde '} 42} {1} 43do_test collateA-1.4 { 44 execsql {SELECT a FROM t1 WHERE b='xyzzy'} 45} {} 46do_test collateA-1.5 { 47 execsql {SELECT a FROM t1 WHERE c='xyzzy'} 48} {2 3 4} 49do_test collateA-1.6 { 50 execsql {SELECT a FROM t1 WHERE c='xyzzy '} 51} {2 3 4} 52do_test collateA-1.7 { 53 execsql {SELECT a FROM t1 WHERE c='xyzzy '} 54} {2 3 4} 55do_test collateA-1.8 { 56 execsql {SELECT a FROM t1 WHERE c='xyzzy '} 57} {2 3 4} 58do_test collateA-1.9 { 59 execsql {SELECT a FROM t1 WHERE c='xyzzy '} 60} {2 3 4} 61do_test collateA-1.10 { 62 execsql {SELECT a FROM t1 WHERE c='xyzzy '} 63} {2 3 4} 64do_test collateA-1.11 { 65 execsql {SELECT 'abc123'='abc123 ' COLLATE RTRIM;} 66} {1} 67do_test collateA-1.12 { 68 execsql {SELECT 'abc123 '='abc123' COLLATE RTRIM;} 69} {1} 70do_test collateA-1.13 { 71 execsql {SELECT ' '='' COLLATE RTRIM, ' '='' COLLATE BINARY, ' '=''} 72} {1 0 0} 73do_test collateA-1.14 { 74 execsql {SELECT ''=' ' COLLATE RTRIM, ''=' ' COLLATE BINARY, ''=' '} 75} {1 0 0} 76do_test collateA-1.15 { 77 execsql {SELECT ' '=' ' COLLATE RTRIM, ' '=' '} 78} {1 0} 79do_test collateA-1.16 { 80 execsql {SELECT ''<>' ' COLLATE RTRIM, ''<>' ' COLLATE BINARY, ''<>' '} 81} {0 1 1} 82do_test collateA-1.17 { 83 execsql {SELECT a FROM t1 WHERE c='xyzz'} 84} {} 85do_test collateA-1.18 { 86 execsql {SELECT a FROM t1 WHERE c='xyzzyy '} 87} {} 88do_test collateA-1.19 { 89 execsql {SELECT a FROM t1 WHERE c='xyzz '} 90} {} 91do_test collateA-1.20 { 92 execsql {SELECT a FROM t1 WHERE c='abcd '} 93} {} 94do_test collateA-1.21 { 95 execsql {SELECT a FROM t1 WHERE c='abcd'} 96} {} 97do_test collateA-1.22 { 98 execsql {SELECT a FROM t1 WHERE c='abc'} 99} {} 100do_test collateA-1.23 { 101 execsql {SELECT a FROM t1 WHERE c='abcdef '} 102} {} 103do_test collateA-1.24 { 104 execsql {SELECT a FROM t1 WHERE c=''} 105} {5 6} 106do_test collateA-1.25 { 107 execsql {SELECT a FROM t1 WHERE c=' '} 108} {5 6} 109do_test collateA-1.26 { 110 execsql {SELECT a FROM t1 WHERE c=' '} 111} {5 6} 112 113 114do_test collateA-2.1 { 115 execsql { 116 CREATE INDEX i1b ON t1(b); 117 CREATE INDEX i1c ON t1(c); 118 PRAGMA integrity_check; 119 } 120} {ok} 121do_test collateA-2.2 { 122 execsql {SELECT a FROM t1 WHERE b='abcde '} 123} {} 124do_test collateA-2.3 { 125 execsql {SELECT a FROM t1 WHERE c='abcde '} 126} {1} 127do_test collateA-2.4 { 128 execsql {SELECT a FROM t1 WHERE b='xyzzy'} 129} {} 130do_test collateA-2.5 { 131 execsql {SELECT a FROM t1 WHERE c='xyzzy'} 132} {2 3 4} 133do_test collateA-2.6 { 134 execsql {SELECT a FROM t1 WHERE c='xyzzy '} 135} {2 3 4} 136do_test collateA-2.7 { 137 execsql {SELECT a FROM t1 WHERE c='xyzzy '} 138} {2 3 4} 139do_test collateA-2.8 { 140 execsql {SELECT a FROM t1 WHERE c='xyzzy '} 141} {2 3 4} 142do_test collateA-2.9 { 143 execsql {SELECT a FROM t1 WHERE c='xyzzy '} 144} {2 3 4} 145do_test collateA-2.10 { 146 execsql {SELECT a FROM t1 WHERE c='xyzzy '} 147} {2 3 4} 148do_test collateA-2.17 { 149 execsql {SELECT a FROM t1 WHERE c='xyzz'} 150} {} 151do_test collateA-2.18 { 152 execsql {SELECT a FROM t1 WHERE c='xyzzyy '} 153} {} 154do_test collateA-2.19 { 155 execsql {SELECT a FROM t1 WHERE c='xyzz '} 156} {} 157do_test collateA-2.20 { 158 execsql {SELECT a FROM t1 WHERE c='abcd '} 159} {} 160do_test collateA-2.21 { 161 execsql {SELECT a FROM t1 WHERE c='abcd'} 162} {} 163do_test collateA-2.22 { 164 execsql {SELECT a FROM t1 WHERE c='abc'} 165} {} 166do_test collateA-2.23 { 167 execsql {SELECT a FROM t1 WHERE c='abcdef '} 168} {} 169do_test collateA-2.24 { 170 execsql {SELECT a FROM t1 WHERE c=''} 171} {5 6} 172do_test collateA-2.25 { 173 execsql {SELECT a FROM t1 WHERE c=' '} 174} {5 6} 175do_test collateA-2.26 { 176 execsql {SELECT a FROM t1 WHERE c=' '} 177} {5 6} 178 179 180do_test collateA-3.1 { 181 db close 182 sqlite3 db test.db 183 execsql { 184 REINDEX; 185 PRAGMA integrity_check; 186 } 187} {ok} 188do_test collateA-3.2 { 189 execsql {SELECT a FROM t1 WHERE b='abcde '} 190} {} 191do_test collateA-3.3 { 192 execsql {SELECT a FROM t1 WHERE c='abcde '} 193} {1} 194do_test collateA-3.4 { 195 execsql {SELECT a FROM t1 WHERE b='xyzzy'} 196} {} 197do_test collateA-3.5 { 198 execsql {SELECT a FROM t1 WHERE c='xyzzy'} 199} {2 3 4} 200do_test collateA-3.6 { 201 execsql {SELECT a FROM t1 WHERE c='xyzzy '} 202} {2 3 4} 203do_test collateA-3.7 { 204 execsql {SELECT a FROM t1 WHERE c='xyzzy '} 205} {2 3 4} 206do_test collateA-3.8 { 207 execsql {SELECT a FROM t1 WHERE c='xyzzy '} 208} {2 3 4} 209do_test collateA-3.9 { 210 execsql {SELECT a FROM t1 WHERE c='xyzzy '} 211} {2 3 4} 212do_test collateA-3.10 { 213 execsql {SELECT a FROM t1 WHERE c='xyzzy '} 214} {2 3 4} 215 216 217finish_test 218