Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: third_party/sqlite/src/test/instr.test

Issue 949043002: Add //third_party/sqlite to dirs_to_snapshot, remove net_sql.patch (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/sqlite/src/test/insert5.test ('k') | third_party/sqlite/src/test/interrupt.test » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # 2012 October 24
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
12 # focus of this file is testing the built-in INSTR() functions.
13 #
14 # EVIDENCE-OF: R-27549-59611 The instr(X,Y) function finds the first
15 # occurrence of string Y within string X and returns the number of prior
16 # characters plus 1, or 0 if Y is nowhere found within X.
17 #
18
19
20 set testdir [file dirname $argv0]
21 source $testdir/tester.tcl
22
23 # Create a table to work with.
24 #
25 do_test instr-1.1 {
26 db eval {SELECT instr('abcdefg','a');}
27 } {1}
28 do_test instr-1.2 {
29 db eval {SELECT instr('abcdefg','b');}
30 } {2}
31 do_test instr-1.3 {
32 db eval {SELECT instr('abcdefg','c');}
33 } {3}
34 do_test instr-1.4 {
35 db eval {SELECT instr('abcdefg','d');}
36 } {4}
37 do_test instr-1.5 {
38 db eval {SELECT instr('abcdefg','e');}
39 } {5}
40 do_test instr-1.6 {
41 db eval {SELECT instr('abcdefg','f');}
42 } {6}
43 do_test instr-1.7 {
44 db eval {SELECT instr('abcdefg','g');}
45 } {7}
46 do_test instr-1.8 {
47 db eval {SELECT instr('abcdefg','h');}
48 } {0}
49 do_test instr-1.9 {
50 db eval {SELECT instr('abcdefg','abcdefg');}
51 } {1}
52 do_test instr-1.10 {
53 db eval {SELECT instr('abcdefg','abcdefgh');}
54 } {0}
55 do_test instr-1.11 {
56 db eval {SELECT instr('abcdefg','bcdefg');}
57 } {2}
58 do_test instr-1.12 {
59 db eval {SELECT instr('abcdefg','bcdefgh');}
60 } {0}
61 do_test instr-1.13 {
62 db eval {SELECT instr('abcdefg','cdefg');}
63 } {3}
64 do_test instr-1.14 {
65 db eval {SELECT instr('abcdefg','cdefgh');}
66 } {0}
67 do_test instr-1.15 {
68 db eval {SELECT instr('abcdefg','defg');}
69 } {4}
70 do_test instr-1.16 {
71 db eval {SELECT instr('abcdefg','defgh');}
72 } {0}
73 do_test instr-1.17 {
74 db eval {SELECT instr('abcdefg','efg');}
75 } {5}
76 do_test instr-1.18 {
77 db eval {SELECT instr('abcdefg','efgh');}
78 } {0}
79 do_test instr-1.19 {
80 db eval {SELECT instr('abcdefg','fg');}
81 } {6}
82 do_test instr-1.20 {
83 db eval {SELECT instr('abcdefg','fgh');}
84 } {0}
85 do_test instr-1.21 {
86 db eval {SELECT coalesce(instr('abcdefg',NULL),'nil');}
87 } {nil}
88 do_test instr-1.22 {
89 db eval {SELECT coalesce(instr(NULL,'x'),'nil');}
90 } {nil}
91 do_test instr-1.23 {
92 db eval {SELECT instr(12345,34);}
93 } {3}
94 do_test instr-1.24 {
95 db eval {SELECT instr(123456.78,34);}
96 } {3}
97 do_test instr-1.25 {
98 db eval {SELECT instr(123456.78,x'3334');}
99 } {3}
100 do_test instr-1.26 {
101 db eval {SELECT instr('äbcdefg','efg');}
102 } {5}
103 do_test instr-1.27 {
104 db eval {SELECT instr('€xyzzy','xyz');}
105 } {2}
106 do_test instr-1.28 {
107 db eval {SELECT instr('abc€xyzzy','xyz');}
108 } {5}
109 do_test instr-1.29 {
110 db eval {SELECT instr('abc€xyzzy','€xyz');}
111 } {4}
112 do_test instr-1.30 {
113 db eval {SELECT instr('abc€xyzzy','c€xyz');}
114 } {3}
115 do_test instr-1.31 {
116 db eval {SELECT instr(x'0102030405',x'01');}
117 } {1}
118 do_test instr-1.32 {
119 db eval {SELECT instr(x'0102030405',x'02');}
120 } {2}
121 do_test instr-1.33 {
122 db eval {SELECT instr(x'0102030405',x'03');}
123 } {3}
124 do_test instr-1.34 {
125 db eval {SELECT instr(x'0102030405',x'04');}
126 } {4}
127 do_test instr-1.35 {
128 db eval {SELECT instr(x'0102030405',x'05');}
129 } {5}
130 do_test instr-1.36 {
131 db eval {SELECT instr(x'0102030405',x'06');}
132 } {0}
133 do_test instr-1.37 {
134 db eval {SELECT instr(x'0102030405',x'0102030405');}
135 } {1}
136 do_test instr-1.38 {
137 db eval {SELECT instr(x'0102030405',x'02030405');}
138 } {2}
139 do_test instr-1.39 {
140 db eval {SELECT instr(x'0102030405',x'030405');}
141 } {3}
142 do_test instr-1.40 {
143 db eval {SELECT instr(x'0102030405',x'0405');}
144 } {4}
145 do_test instr-1.41 {
146 db eval {SELECT instr(x'0102030405',x'0506');}
147 } {0}
148 do_test instr-1.42 {
149 db eval {SELECT instr(x'0102030405',x'');}
150 } {1}
151 do_test instr-1.43 {
152 db eval {SELECT instr(x'',x'');}
153 } {1}
154 do_test instr-1.44 {
155 db eval {SELECT instr('','');}
156 } {1}
157 do_test instr-1.45 {
158 db eval {SELECT instr('abcdefg','');}
159 } {1}
160 unset -nocomplain longstr
161 set longstr abcdefghijklmonpqrstuvwxyz
162 append longstr $longstr
163 append longstr $longstr
164 append longstr $longstr
165 append longstr $longstr
166 append longstr $longstr
167 append longstr $longstr
168 append longstr $longstr
169 append longstr $longstr
170 append longstr $longstr
171 append longstr $longstr
172 append longstr $longstr
173 append longstr $longstr
174 # puts [string length $longstr]
175 append longstr Xabcde
176 do_test instr-1.46 {
177 db eval {SELECT instr($longstr,'X');}
178 } {106497}
179 do_test instr-1.47 {
180 db eval {SELECT instr($longstr,'Y');}
181 } {0}
182 do_test instr-1.48 {
183 db eval {SELECT instr($longstr,'Xa');}
184 } {106497}
185 do_test instr-1.49 {
186 db eval {SELECT instr($longstr,'zXa');}
187 } {106496}
188 set longstr [string map {a ä} $longstr]
189 do_test instr-1.50 {
190 db eval {SELECT instr($longstr,'X');}
191 } {106497}
192 do_test instr-1.51 {
193 db eval {SELECT instr($longstr,'Y');}
194 } {0}
195 do_test instr-1.52 {
196 db eval {SELECT instr($longstr,'Xä');}
197 } {106497}
198 do_test instr-1.53 {
199 db eval {SELECT instr($longstr,'zXä');}
200 } {106496}
201 do_test instr-1.54 {
202 db eval {SELECT instr(x'78c3a4e282ac79','x');}
203 } {1}
204 do_test instr-1.55 {
205 db eval {SELECT instr(x'78c3a4e282ac79','y');}
206 } {4}
207
208 # EVIDENCE-OF: R-46421-32541 Or, if X and Y are both BLOBs, then
209 # instr(X,Y) returns one more than the number bytes prior to the first
210 # occurrence of Y, or 0 if Y does not occur anywhere within X.
211 #
212 do_test instr-1.56.1 {
213 db eval {SELECT instr(x'78c3a4e282ac79',x'79');}
214 } {7}
215 do_test instr-1.56.2 {
216 db eval {SELECT instr(x'78c3a4e282ac79',x'7a');}
217 } {0}
218 do_test instr-1.56.3 {
219 db eval {SELECT instr(x'78c3a4e282ac79',x'78');}
220 } {1}
221 do_test instr-1.56.3 {
222 db eval {SELECT instr(x'78c3a4e282ac79',x'a4');}
223 } {3}
224
225 # EVIDENCE-OF: R-17329-35644 If both arguments X and Y to instr(X,Y) are
226 # non-NULL and are not BLOBs then both are interpreted as strings.
227 #
228 do_test instr-1.57.1 {
229 db eval {SELECT instr('xä€y',x'79');}
230 } {4}
231 do_test instr-1.57.2 {
232 db eval {SELECT instr('xä€y',x'a4');}
233 } {0}
234 do_test instr-1.57.3 {
235 db eval {SELECT instr(x'78c3a4e282ac79','y');}
236 } {4}
237
238 # EVIDENCE-OF: R-14708-27487 If either X or Y are NULL in instr(X,Y)
239 # then the result is NULL.
240 #
241 do_execsql_test instr-1.60 {
242 SELECT coalesce(instr(NULL,'abc'), 999);
243 } {999}
244 do_execsql_test instr-1.61 {
245 SELECT coalesce(instr('abc',NULL), 999);
246 } {999}
247 do_execsql_test instr-1.62 {
248 SELECT coalesce(instr(NULL,NULL), 999);
249 } {999}
250
251 finish_test
OLDNEW
« no previous file with comments | « third_party/sqlite/src/test/insert5.test ('k') | third_party/sqlite/src/test/interrupt.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698