blob: c9d39cbf3a756ec1cb734204a4985966cb1279aa (
plain)
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
|
# 2002 May 24
#
# 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 of the proper handling of conversions
# to the native text representation.
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
ifcapable {utf16} {
do_test enc3-1.1 {
execsql {
PRAGMA encoding=utf16le;
PRAGMA encoding;
}
} {UTF-16le}
}
do_test enc3-1.2 {
execsql {
CREATE TABLE t1(x,y);
INSERT INTO t1 VALUES('abc''123',5);
SELECT * FROM t1
}
} {abc'123 5}
do_test enc3-1.3 {
execsql {
SELECT quote(x) || ' ' || quote(y) FROM t1
}
} {{'abc''123' 5}}
ifcapable {bloblit} {
do_test enc3-1.4 {
execsql {
DELETE FROM t1;
INSERT INTO t1 VALUES(x'616263646566',NULL);
SELECT * FROM t1
}
} {abcdef {}}
do_test enc3-1.5 {
execsql {
SELECT quote(x) || ' ' || quote(y) FROM t1
}
} {{X'616263646566' NULL}}
}
ifcapable {bloblit && utf16} {
do_test enc3-2.1 {
execsql {
PRAGMA encoding
}
} {UTF-16le}
do_test enc3-2.2 {
execsql {
CREATE TABLE t2(a);
INSERT INTO t2 VALUES(x'61006200630064006500');
SELECT CAST(a AS text) FROM t2 WHERE CAST(a AS text) LIKE 'abc%';
}
} {abcde}
do_test enc3-2.3 {
execsql {
SELECT CAST(x'61006200630064006500' AS text);
}
} {abcde}
do_test enc3-2.4 {
execsql {
SELECT rowid FROM t2
WHERE CAST(a AS text) LIKE CAST(x'610062002500' AS text);
}
} {1}
}
# Try to attach a database with a different encoding.
#
ifcapable {utf16 && shared_cache} {
db close
forcedelete test8.db test8.db-journal
set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
sqlite3 dbaux test8.db
sqlite3 db test.db
db eval {SELECT 1 FROM sqlite_master LIMIT 1}
do_test enc3-3.1 {
dbaux eval {
PRAGMA encoding='utf8';
CREATE TABLE t1(x);
PRAGMA encoding
}
} {UTF-8}
do_test enc3-3.2 {
catchsql {
ATTACH 'test.db' AS utf16;
SELECT 1 FROM utf16.sqlite_master LIMIT 1;
} dbaux
} {1 {attached databases must use the same text encoding as main database}}
dbaux close
forcedelete test8.db test8.db-journal
sqlite3_enable_shared_cache $::enable_shared_cache
}
finish_test
|