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