Annotation of embedaddon/sqlite3/test/collate7.test, revision 1.1

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>