os/persistentdata/persistentstorage/sqlite3api/TEST/TclScript/collate7.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
# 2007 May 7
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 experimental sqlite3_create_collation_v2()
sl@0
    14
# API.
sl@0
    15
#
sl@0
    16
# $Id: collate7.test,v 1.2 2008/07/12 14:52:20 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
set ::caseless_del 0
sl@0
    22
proc caseless_cmp {zLeft zRight} {
sl@0
    23
  string compare -nocase $zLeft $zRight
sl@0
    24
}
sl@0
    25
sl@0
    26
do_test collate7-1.1 {
sl@0
    27
  set cmd [list incr ::caseless_del]
sl@0
    28
  sqlite3_create_collation_v2 db CASELESS caseless_cmp $cmd
sl@0
    29
  set ::caseless_del
sl@0
    30
} {0}
sl@0
    31
do_test collate7-1.2 {
sl@0
    32
  sqlite_delete_collation db CASELESS
sl@0
    33
  set ::caseless_del
sl@0
    34
} {1}
sl@0
    35
do_test collate7-1.3 {
sl@0
    36
  catchsql {
sl@0
    37
    CREATE TABLE abc(a COLLATE CASELESS, b, c);
sl@0
    38
  }
sl@0
    39
} {1 {no such collation sequence: CASELESS}}
sl@0
    40
do_test collate7-1.4 {
sl@0
    41
  sqlite3_create_collation_v2 db CASELESS caseless_cmp {incr ::caseless_del}
sl@0
    42
  db close
sl@0
    43
  set ::caseless_del
sl@0
    44
} {2}
sl@0
    45
sl@0
    46
do_test collate7-2.1 {
sl@0
    47
  file delete -force test.db test.db-journal
sl@0
    48
  sqlite3 db test.db
sl@0
    49
  sqlite3_create_collation_v2 db CASELESS caseless_cmp {incr ::caseless_del}
sl@0
    50
  execsql {
sl@0
    51
    PRAGMA encoding='utf-16';
sl@0
    52
    CREATE TABLE abc16(a COLLATE CASELESS, b, c);
sl@0
    53
  } db
sl@0
    54
  set ::caseless_del
sl@0
    55
} {2}
sl@0
    56
do_test collate7-2.2 {
sl@0
    57
  execsql {
sl@0
    58
    SELECT * FROM abc16 WHERE a < 'abc';
sl@0
    59
  }
sl@0
    60
  set ::caseless_del
sl@0
    61
} {2}
sl@0
    62
do_test collate7-2.3 {
sl@0
    63
  sqlite_delete_collation db CASELESS
sl@0
    64
  set ::caseless_del
sl@0
    65
} {3}
sl@0
    66
do_test collate7-2.4 {
sl@0
    67
  catchsql {
sl@0
    68
    SELECT * FROM abc16 WHERE a < 'abc';
sl@0
    69
  }
sl@0
    70
} {1 {no such collation sequence: CASELESS}}
sl@0
    71
sl@0
    72
finish_test