diff options
Diffstat (limited to 'libraries/sqlite/unix/sqlite-3.5.1/test/ptrchng.test')
-rw-r--r-- | libraries/sqlite/unix/sqlite-3.5.1/test/ptrchng.test | 222 |
1 files changed, 222 insertions, 0 deletions
diff --git a/libraries/sqlite/unix/sqlite-3.5.1/test/ptrchng.test b/libraries/sqlite/unix/sqlite-3.5.1/test/ptrchng.test new file mode 100644 index 0000000..69bc193 --- /dev/null +++ b/libraries/sqlite/unix/sqlite-3.5.1/test/ptrchng.test | |||
@@ -0,0 +1,222 @@ | |||
1 | # 2007 April 27 | ||
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. | ||
12 | # | ||
13 | # The focus of the tests in this file are to verify that the | ||
14 | # underlying TEXT or BLOB representation of an sqlite3_value | ||
15 | # changes appropriately when APIs from the following set are | ||
16 | # called: | ||
17 | # | ||
18 | # sqlite3_value_text() | ||
19 | # sqlite3_value_text16() | ||
20 | # sqlite3_value_blob() | ||
21 | # sqlite3_value_bytes() | ||
22 | # sqlite3_value_bytes16() | ||
23 | # | ||
24 | # $Id: ptrchng.test,v 1.2 2007/09/12 17:01:45 danielk1977 Exp $ | ||
25 | |||
26 | set testdir [file dirname $argv0] | ||
27 | source $testdir/tester.tcl | ||
28 | |||
29 | ifcapable !bloblit { | ||
30 | finish_test | ||
31 | return | ||
32 | } | ||
33 | |||
34 | # Register the "pointer_change" SQL function. | ||
35 | # | ||
36 | sqlite3_create_function db | ||
37 | |||
38 | do_test ptrchng-1.1 { | ||
39 | execsql { | ||
40 | CREATE TABLE t1(x INTEGER PRIMARY KEY, y BLOB); | ||
41 | INSERT INTO t1 VALUES(1, 'abc'); | ||
42 | INSERT INTO t1 VALUES(2, | ||
43 | 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234356789'); | ||
44 | INSERT INTO t1 VALUES(3, x'626c6f62'); | ||
45 | INSERT INTO t1 VALUES(4, | ||
46 | x'000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f2021222324' | ||
47 | ); | ||
48 | SELECT count(*) FROM t1; | ||
49 | } | ||
50 | } {4} | ||
51 | |||
52 | # For the short entries that fit in the Mem.zBuf[], the pointer should | ||
53 | # never change regardless of what type conversions occur. | ||
54 | # | ||
55 | do_test ptrchng-2.1 { | ||
56 | execsql { | ||
57 | SELECT pointer_change(y, 'text', 'noop', 'blob') FROM t1 WHERE x=1 | ||
58 | } | ||
59 | } {0} | ||
60 | do_test ptrchng-2.2 { | ||
61 | execsql { | ||
62 | SELECT pointer_change(y, 'blob', 'noop', 'text') FROM t1 WHERE x=1 | ||
63 | } | ||
64 | } {0} | ||
65 | ifcapable utf16 { | ||
66 | do_test ptrchng-2.3 { | ||
67 | execsql { | ||
68 | SELECT pointer_change(y, 'text', 'noop', 'text16') FROM t1 WHERE x=1 | ||
69 | } | ||
70 | } {0} | ||
71 | do_test ptrchng-2.4 { | ||
72 | execsql { | ||
73 | SELECT pointer_change(y, 'blob', 'noop', 'text16') FROM t1 WHERE x=1 | ||
74 | } | ||
75 | } {0} | ||
76 | do_test ptrchng-2.5 { | ||
77 | execsql { | ||
78 | SELECT pointer_change(y, 'text16', 'noop', 'blob') FROM t1 WHERE x=1 | ||
79 | } | ||
80 | } {0} | ||
81 | do_test ptrchng-2.6 { | ||
82 | execsql { | ||
83 | SELECT pointer_change(y, 'text16', 'noop', 'text') FROM t1 WHERE x=1 | ||
84 | } | ||
85 | } {0} | ||
86 | } | ||
87 | do_test ptrchng-2.11 { | ||
88 | execsql { | ||
89 | SELECT pointer_change(y, 'text', 'noop', 'blob') FROM t1 WHERE x=3 | ||
90 | } | ||
91 | } {0} | ||
92 | do_test ptrchng-2.12 { | ||
93 | execsql { | ||
94 | SELECT pointer_change(y, 'blob', 'noop', 'text') FROM t1 WHERE x=3 | ||
95 | } | ||
96 | } {0} | ||
97 | ifcapable utf16 { | ||
98 | do_test ptrchng-2.13 { | ||
99 | execsql { | ||
100 | SELECT pointer_change(y, 'text', 'noop', 'text16') FROM t1 WHERE x=3 | ||
101 | } | ||
102 | } {0} | ||
103 | do_test ptrchng-2.14 { | ||
104 | execsql { | ||
105 | SELECT pointer_change(y, 'blob', 'noop', 'text16') FROM t1 WHERE x=3 | ||
106 | } | ||
107 | } {0} | ||
108 | do_test ptrchng-2.15 { | ||
109 | execsql { | ||
110 | SELECT pointer_change(y, 'text16', 'noop', 'blob') FROM t1 WHERE x=3 | ||
111 | } | ||
112 | } {0} | ||
113 | do_test ptrchng-2.16 { | ||
114 | btree_breakpoint | ||
115 | execsql { | ||
116 | SELECT pointer_change(y, 'text16', 'noop', 'text') FROM t1 WHERE x=3 | ||
117 | } | ||
118 | } {0} | ||
119 | } | ||
120 | |||
121 | # For the long entries that do not fit in the Mem.zBuf[], the pointer | ||
122 | # should change sometimes. | ||
123 | # | ||
124 | do_test ptrchng-3.1 { | ||
125 | execsql { | ||
126 | SELECT pointer_change(y, 'text', 'noop', 'blob') FROM t1 WHERE x=2 | ||
127 | } | ||
128 | } {0} | ||
129 | do_test ptrchng-3.2 { | ||
130 | execsql { | ||
131 | SELECT pointer_change(y, 'blob', 'noop', 'text') FROM t1 WHERE x=2 | ||
132 | } | ||
133 | } {0} | ||
134 | ifcapable utf16 { | ||
135 | do_test ptrchng-3.3 { | ||
136 | execsql { | ||
137 | SELECT pointer_change(y, 'text', 'noop', 'text16') FROM t1 WHERE x=2 | ||
138 | } | ||
139 | } {1} | ||
140 | do_test ptrchng-3.4 { | ||
141 | execsql { | ||
142 | SELECT pointer_change(y, 'blob', 'noop', 'text16') FROM t1 WHERE x=2 | ||
143 | } | ||
144 | } {1} | ||
145 | do_test ptrchng-3.5 { | ||
146 | execsql { | ||
147 | SELECT pointer_change(y, 'text16', 'noop', 'blob') FROM t1 WHERE x=2 | ||
148 | } | ||
149 | } {0} | ||
150 | do_test ptrchng-3.6 { | ||
151 | execsql { | ||
152 | SELECT pointer_change(y, 'text16', 'noop', 'text') FROM t1 WHERE x=2 | ||
153 | } | ||
154 | } {1} | ||
155 | } | ||
156 | do_test ptrchng-3.11 { | ||
157 | execsql { | ||
158 | SELECT pointer_change(y, 'text', 'noop', 'blob') FROM t1 WHERE x=4 | ||
159 | } | ||
160 | } {0} | ||
161 | do_test ptrchng-3.12 { | ||
162 | execsql { | ||
163 | SELECT pointer_change(y, 'blob', 'noop', 'text') FROM t1 WHERE x=4 | ||
164 | } | ||
165 | } {0} | ||
166 | ifcapable utf16 { | ||
167 | do_test ptrchng-3.13 { | ||
168 | execsql { | ||
169 | SELECT pointer_change(y, 'text', 'noop', 'text16') FROM t1 WHERE x=4 | ||
170 | } | ||
171 | } {1} | ||
172 | do_test ptrchng-3.14 { | ||
173 | execsql { | ||
174 | SELECT pointer_change(y, 'blob', 'noop', 'text16') FROM t1 WHERE x=4 | ||
175 | } | ||
176 | } {1} | ||
177 | do_test ptrchng-3.15 { | ||
178 | execsql { | ||
179 | SELECT pointer_change(y, 'text16', 'noop', 'blob') FROM t1 WHERE x=4 | ||
180 | } | ||
181 | } {0} | ||
182 | do_test ptrchng-3.16 { | ||
183 | execsql { | ||
184 | SELECT pointer_change(y, 'text16', 'noop', 'text') FROM t1 WHERE x=4 | ||
185 | } | ||
186 | } {1} | ||
187 | } | ||
188 | |||
189 | # A call to _bytes() should never reformat a _text() or _blob(). | ||
190 | # | ||
191 | do_test ptrchng-4.1 { | ||
192 | execsql { | ||
193 | SELECT pointer_change(y, 'text', 'bytes', 'text') FROM t1 | ||
194 | } | ||
195 | } {0 0 0 0} | ||
196 | do_test ptrchng-4.2 { | ||
197 | execsql { | ||
198 | SELECT pointer_change(y, 'blob', 'bytes', 'blob') FROM t1 | ||
199 | } | ||
200 | } {0 0 0 0} | ||
201 | |||
202 | # A call to _blob() should never trigger a reformat | ||
203 | # | ||
204 | do_test ptrchng-5.1 { | ||
205 | execsql { | ||
206 | SELECT pointer_change(y, 'text', 'bytes', 'blob') FROM t1 | ||
207 | } | ||
208 | } {0 0 0 0} | ||
209 | ifcapable utf16 { | ||
210 | do_test ptrchng-5.2 { | ||
211 | execsql { | ||
212 | SELECT pointer_change(y, 'text16', 'noop', 'blob') FROM t1 | ||
213 | } | ||
214 | } {0 0 0 0} | ||
215 | do_test ptrchng-5.3 { | ||
216 | execsql { | ||
217 | SELECT pointer_change(y, 'text16', 'bytes16', 'blob') FROM t1 | ||
218 | } | ||
219 | } {0 0 0 0} | ||
220 | } | ||
221 | |||
222 | finish_test | ||