/ Check-in [c7f93636]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Additional encoding tests.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | experimental
Files: files | file ages | folders
SHA1: c7f9363617a66ee43a87816ad42aaf2b75f13ea2
User & Date: shaneh 2010-09-30 18:19:44
Context
2010-09-30
18:30
Fix memory leak in enc4.test script. check-in: bfc294ae user: shaneh tags: experimental
18:19
Additional encoding tests. check-in: c7f93636 user: shaneh tags: experimental
18:12
Remove unnecessary calls to memAboutToChange() in vdbe.c. An affinity change no longer invalidates shallow copies. check-in: afb0fd0b user: drh tags: experimental
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Added test/enc4.test.

























































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# 2010 Sept 29
#
# The author disclaims copyright to this source code.  In place of
# a legal notice, here is a blessing:
#
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library.  The focus of
# this file is testing the SQLite routines used for converting between the
# various suported unicode encodings (UTF-8, UTF-16, UTF-16le and
# UTF-16be).
#
# $Id: enc4.test,v 1.0 2010/09/29 08:29:32 shaneh Exp $

set testdir [file dirname $argv0]
source $testdir/tester.tcl

# If UTF16 support is disabled, ignore the tests in this file
#
ifcapable {!utf16} {
  finish_test
  return
}

db close

# The three unicode encodings understood by SQLite.
set encodings [list UTF-8 UTF-16le UTF-16be]

# initial value to use in SELECT
set inits [list 1 1.0]

# vals
set vals [list\
"922337203685477580792233720368547758079223372036854775807"\
"100000000000000000000000000000000000000000000000000000000"\
"1.0000000000000000000000000000000000000000000000000000000"\
]

set i 1
foreach enc $encodings {

  file delete -force test.db
  sqlite3 db test.db
  db eval "PRAGMA encoding = \"$enc\""

  do_test enc4-$i.1 {
    db eval {PRAGMA encoding}
  } $enc

  set j 1
  foreach init $inits {

    do_test enc4-$i.$j.2 {
      set S [sqlite3_prepare_v2 db "SELECT $init+?" -1 dummy]
      sqlite3_expired $S
    } {0}
      
    set k 1
    foreach val $vals {
      for {set x 1} {$x<18} {incr x} {
        set part [expr $init + [string range $val 0 [expr $x-1]]]

        do_test enc4-$i.$j.$k.3.$x {
          sqlite3_reset $S
          sqlite3_bind_text $S 1 $val $x
          sqlite3_step $S
          sqlite3_column_text $S 0
        } [list $part]
        
        do_test enc4-$i.$j.$k.4.$x {
          sqlite3_reset $S
          sqlite3_bind_text16 $S 1 [encoding convertto unicode $val] [expr $x*2]
          sqlite3_step $S
          sqlite3_column_text $S 0
        } [list $part]
      }
      
      incr k
    }

    do_test enc4-$i.$j.5 {
      sqlite3_finalize $S
    } {SQLITE_OK}

    incr j
  }

  db close
  incr i
}

file delete -force test.db
sqlite3 db test.db

do_test enc4-4.1 {
  db eval "select 1+1."
} {2.0}

do_test enc4-4.2 {
  set S [sqlite3_prepare_v2 db "SELECT 1+1." -1 dummy]
  sqlite3_step $S
  sqlite3_column_text $S 0
} {2.0}

do_test enc4-4.3 {
  set S [sqlite3_prepare_v2 db "SELECT 1+?" -1 dummy]
  sqlite3_bind_text $S 1 "1." 2
  sqlite3_step $S
  sqlite3_column_text $S 0
} {2.0}

do_test enc4-4.4 {
  set S [sqlite3_prepare_v2 db "SELECT 1+?" -1 dummy]
  sqlite3_bind_text $S 1 "1.0" 2
  sqlite3_step $S
  sqlite3_column_text $S 0
} {2.0}


finish_test