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

1.1     ! misho       1: # 2010 Sept 29
        !             2: #
        !             3: # The author disclaims copyright to this source code.  In place of
        !             4: # a legal notice, here is a blessing:
        !             5: #
        !             6: #    May you do good and not evil.
        !             7: #    May you find forgiveness for yourself and forgive others.
        !             8: #    May you share freely, never taking more than you give.
        !             9: #
        !            10: #***********************************************************************
        !            11: # This file implements regression tests for SQLite library.  The focus of
        !            12: # this file is testing the SQLite routines used for converting between the
        !            13: # various suported unicode encodings (UTF-8, UTF-16, UTF-16le and
        !            14: # UTF-16be).
        !            15: #
        !            16: # $Id: enc4.test,v 1.0 2010/09/29 08:29:32 shaneh Exp $
        !            17: 
        !            18: set testdir [file dirname $argv0]
        !            19: source $testdir/tester.tcl
        !            20: 
        !            21: # If UTF16 support is disabled, ignore the tests in this file
        !            22: #
        !            23: ifcapable {!utf16} {
        !            24:   finish_test
        !            25:   return
        !            26: }
        !            27: 
        !            28: db close
        !            29: 
        !            30: # The three unicode encodings understood by SQLite.
        !            31: set encodings [list UTF-8 UTF-16le UTF-16be]
        !            32: 
        !            33: # initial value to use in SELECT
        !            34: set inits [list 1 1.0 1. 1e0]
        !            35: 
        !            36: # vals
        !            37: set vals [list\
        !            38: "922337203685477580792233720368547758079223372036854775807"\
        !            39: "100000000000000000000000000000000000000000000000000000000"\
        !            40: "1.0000000000000000000000000000000000000000000000000000000"\
        !            41: ]
        !            42: 
        !            43: set i 1
        !            44: foreach enc $encodings {
        !            45: 
        !            46:   forcedelete test.db
        !            47:   sqlite3 db test.db
        !            48:   db eval "PRAGMA encoding = \"$enc\""
        !            49: 
        !            50:   do_test enc4-$i.1 {
        !            51:     db eval {PRAGMA encoding}
        !            52:   } $enc
        !            53: 
        !            54:   set j 1
        !            55:   foreach init $inits {
        !            56: 
        !            57:     do_test enc4-$i.$j.2 {
        !            58:       set S [sqlite3_prepare_v2 db "SELECT $init+?" -1 dummy]
        !            59:       sqlite3_expired $S
        !            60:     } {0}
        !            61:       
        !            62:     set k 1
        !            63:     foreach val $vals {
        !            64:       for {set x 1} {$x<16} {incr x} {
        !            65:         set part [expr $init + [string range $val 0 [expr $x-1]]]
        !            66: 
        !            67:         do_realnum_test enc4-$i.$j.$k.3.$x {
        !            68:           sqlite3_reset $S
        !            69:           sqlite3_bind_text $S 1 $val $x
        !            70:           sqlite3_step $S
        !            71:           sqlite3_column_text $S 0
        !            72:         } [list $part]
        !            73:         
        !            74:         do_realnum_test enc4-$i.$j.$k.4.$x {
        !            75:           sqlite3_reset $S
        !            76:           sqlite3_bind_text16 $S 1 [encoding convertto unicode $val] [expr $x*2]
        !            77:           sqlite3_step $S
        !            78:           sqlite3_column_text $S 0
        !            79:         } [list $part]
        !            80:       }
        !            81:       
        !            82:       incr k
        !            83:     }
        !            84: 
        !            85:     do_test enc4-$i.$j.5 {
        !            86:       sqlite3_finalize $S
        !            87:     } {SQLITE_OK}
        !            88: 
        !            89:     incr j
        !            90:   }
        !            91: 
        !            92:   db close
        !            93:   incr i
        !            94: }
        !            95: 
        !            96: forcedelete test.db
        !            97: sqlite3 db test.db
        !            98: 
        !            99: do_test enc4-4.1 {
        !           100:   db eval "select 1+1."
        !           101: } {2.0}
        !           102: 
        !           103: do_test enc4-4.2.1 {
        !           104:   set S [sqlite3_prepare_v2 db "SELECT 1+1." -1 dummy]
        !           105:   sqlite3_step $S
        !           106:   sqlite3_column_text $S 0
        !           107: } {2.0}
        !           108: 
        !           109: do_test enc4-4.2.2 {
        !           110:   sqlite3_finalize $S
        !           111: } {SQLITE_OK}
        !           112: 
        !           113: do_test enc4-4.3.1 {
        !           114:   set S [sqlite3_prepare_v2 db "SELECT 1+?" -1 dummy]
        !           115:   sqlite3_bind_text $S 1 "1." 2
        !           116:   sqlite3_step $S
        !           117:   sqlite3_column_text $S 0
        !           118: } {2.0}
        !           119: 
        !           120: do_test enc4-4.3.2 {
        !           121:   sqlite3_finalize $S
        !           122: } {SQLITE_OK}
        !           123: 
        !           124: do_test enc4-4.4.1 {
        !           125:   set S [sqlite3_prepare_v2 db "SELECT 1+?" -1 dummy]
        !           126:   sqlite3_bind_text $S 1 "1.0" 2
        !           127:   sqlite3_step $S
        !           128:   sqlite3_column_text $S 0
        !           129: } {2.0}
        !           130: 
        !           131: do_test enc4-4.4.2 {
        !           132:   sqlite3_finalize $S
        !           133: } {SQLITE_OK}
        !           134: 
        !           135: db close
        !           136: 
        !           137: finish_test

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