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

Side by Side Diff: third_party/sqlite/src/test/func3.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/func.test ('k') | third_party/sqlite/src/test/func4.test » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # 2010 August 27 1 # 2010 August 27
2 # 2 #
3 # The author disclaims copyright to this source code. In place of 3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing: 4 # a legal notice, here is a blessing:
5 # 5 #
6 # May you do good and not evil. 6 # May you do good and not evil.
7 # May you find forgiveness for yourself and forgive others. 7 # May you find forgiveness for yourself and forgive others.
8 # May you share freely, never taking more than you give. 8 # May you share freely, never taking more than you give.
9 # 9 #
10 #*********************************************************************** 10 #***********************************************************************
11 # This file implements regression tests for SQLite library. The 11 # This file implements regression tests for SQLite library. The
12 # focus of this file is testing that destructor functions associated 12 # focus of this file is testing that destructor functions associated
13 # with functions created using sqlite3_create_function_v2() is 13 # with functions created using sqlite3_create_function_v2() is
14 # correctly invoked. 14 # correctly invoked.
15 # 15 #
16 set testdir [file dirname $argv0] 16 set testdir [file dirname $argv0]
17 source $testdir/tester.tcl 17 source $testdir/tester.tcl
18 18
19 19
20 do_test func3-1.1 { 20 ifcapable utf16 {
21 set destroyed 0 21 do_test func3-1.1 {
22 proc destroy {} { set ::destroyed 1 } 22 set destroyed 0
23 sqlite3_create_function_v2 db f2 -1 any -func f2 -destroy destroy 23 proc destroy {} { set ::destroyed 1 }
24 set destroyed 24 sqlite3_create_function_v2 db f2 -1 any -func f2 -destroy destroy
25 } 0 25 set destroyed
26 do_test func3-1.2 { 26 } 0
27 sqlite3_create_function_v2 db f2 -1 utf8 -func f2 27 do_test func3-1.2 {
28 set destroyed 28 sqlite3_create_function_v2 db f2 -1 utf8 -func f2
29 } 0 29 set destroyed
30 do_test func3-1.3 { 30 } 0
31 sqlite3_create_function_v2 db f2 -1 utf16le -func f2 31 do_test func3-1.3 {
32 set destroyed 32 sqlite3_create_function_v2 db f2 -1 utf16le -func f2
33 } 0 33 set destroyed
34 do_test func3-1.4 { 34 } 0
35 sqlite3_create_function_v2 db f2 -1 utf16be -func f2 35 do_test func3-1.4 {
36 set destroyed 36 sqlite3_create_function_v2 db f2 -1 utf16be -func f2
37 } 1 37 set destroyed
38 } 1
39 }
38 40
39 do_test func3-2.1 { 41 do_test func3-2.1 {
40 set destroyed 0 42 set destroyed 0
41 proc destroy {} { set ::destroyed 1 } 43 proc destroy {} { set ::destroyed 1 }
42 sqlite3_create_function_v2 db f3 -1 utf8 -func f3 -destroy destroy 44 sqlite3_create_function_v2 db f3 -1 utf8 -func f3 -destroy destroy
43 set destroyed 45 set destroyed
44 } 0 46 } 0
45 do_test func3-2.2 { 47 do_test func3-2.2 {
46 sqlite3_create_function_v2 db f3 -1 utf8 -func f3 48 sqlite3_create_function_v2 db f3 -1 utf8 -func f3
47 set destroyed 49 set destroyed
(...skipping 13 matching lines...) Expand all
61 sqlite3 db test.db 63 sqlite3 db test.db
62 do_test func3-4.1 { 64 do_test func3-4.1 {
63 set destroyed 0 65 set destroyed 0
64 set rc [catch { 66 set rc [catch {
65 sqlite3_create_function_v2 db f3 -1 any -func f3 -step f3 -destroy destroy 67 sqlite3_create_function_v2 db f3 -1 any -func f3 -step f3 -destroy destroy
66 } msg] 68 } msg]
67 list $rc $msg 69 list $rc $msg
68 } {1 SQLITE_MISUSE} 70 } {1 SQLITE_MISUSE}
69 do_test func3-4.2 { set destroyed } 1 71 do_test func3-4.2 { set destroyed } 1
70 72
73 # EVIDENCE-OF: R-41921-05214 The likelihood(X,Y) function returns
74 # argument X unchanged.
75 #
76 do_execsql_test func3-5.1 {
77 SELECT likelihood(9223372036854775807, 0.5);
78 } {9223372036854775807}
79 do_execsql_test func3-5.2 {
80 SELECT likelihood(-9223372036854775808, 0.5);
81 } {-9223372036854775808}
82 do_execsql_test func3-5.3 {
83 SELECT likelihood(14.125, 0.5);
84 } {14.125}
85 do_execsql_test func3-5.4 {
86 SELECT likelihood(NULL, 0.5);
87 } {{}}
88 do_execsql_test func3-5.5 {
89 SELECT likelihood('test-string', 0.5);
90 } {test-string}
91 do_execsql_test func3-5.6 {
92 SELECT quote(likelihood(x'010203000405', 0.5));
93 } {X'010203000405'}
94
95 # EVIDENCE-OF: R-44133-61651 The value Y in likelihood(X,Y) must be a
96 # floating point constant between 0.0 and 1.0, inclusive.
97 #
98 do_execsql_test func3-5.7 {
99 SELECT likelihood(123, 1.0), likelihood(456, 0.0);
100 } {123 456}
101 do_test func3-5.8 {
102 catchsql {
103 SELECT likelihood(123, 1.000001);
104 }
105 } {1 {second argument to likelihood() must be a constant between 0.0 and 1.0}}
106 do_test func3-5.9 {
107 catchsql {
108 SELECT likelihood(123, -0.000001);
109 }
110 } {1 {second argument to likelihood() must be a constant between 0.0 and 1.0}}
111 do_test func3-5.10 {
112 catchsql {
113 SELECT likelihood(123, 0.5+0.3);
114 }
115 } {1 {second argument to likelihood() must be a constant between 0.0 and 1.0}}
116
117 # EVIDENCE-OF: R-28535-44631 The likelihood(X) function is a no-op that
118 # the code generator optimizes away so that it consumes no CPU cycles
119 # during run-time (that is, during calls to sqlite3_step()).
120 #
121 do_test func3-5.20 {
122 db eval {EXPLAIN SELECT likelihood(min(1.0+'2.0',4*11), 0.5)}
123 } [db eval {EXPLAIN SELECT min(1.0+'2.0',4*11)}]
124
125
126 # EVIDENCE-OF: R-11152-23456 The unlikely(X) function returns the
127 # argument X unchanged.
128 #
129 do_execsql_test func3-5.30 {
130 SELECT unlikely(9223372036854775807);
131 } {9223372036854775807}
132 do_execsql_test func3-5.31 {
133 SELECT unlikely(-9223372036854775808);
134 } {-9223372036854775808}
135 do_execsql_test func3-5.32 {
136 SELECT unlikely(14.125);
137 } {14.125}
138 do_execsql_test func3-5.33 {
139 SELECT unlikely(NULL);
140 } {{}}
141 do_execsql_test func3-5.34 {
142 SELECT unlikely('test-string');
143 } {test-string}
144 do_execsql_test func3-5.35 {
145 SELECT quote(unlikely(x'010203000405'));
146 } {X'010203000405'}
147
148 # EVIDENCE-OF: R-22887-63324 The unlikely(X) function is a no-op that
149 # the code generator optimizes away so that it consumes no CPU cycles at
150 # run-time (that is, during calls to sqlite3_step()).
151 #
152 do_test func3-5.39 {
153 db eval {EXPLAIN SELECT unlikely(min(1.0+'2.0',4*11))}
154 } [db eval {EXPLAIN SELECT min(1.0+'2.0',4*11)}]
155
156
157 # EVIDENCE-OF: R-23735-03107 The likely(X) function returns the argument
158 # X unchanged.
159 #
160 do_execsql_test func3-5.50 {
161 SELECT likely(9223372036854775807);
162 } {9223372036854775807}
163 do_execsql_test func3-5.51 {
164 SELECT likely(-9223372036854775808);
165 } {-9223372036854775808}
166 do_execsql_test func3-5.52 {
167 SELECT likely(14.125);
168 } {14.125}
169 do_execsql_test func3-5.53 {
170 SELECT likely(NULL);
171 } {{}}
172 do_execsql_test func3-5.54 {
173 SELECT likely('test-string');
174 } {test-string}
175 do_execsql_test func3-5.55 {
176 SELECT quote(likely(x'010203000405'));
177 } {X'010203000405'}
178
179 # EVIDENCE-OF: R-43464-09689 The likely(X) function is a no-op that the
180 # code generator optimizes away so that it consumes no CPU cycles at
181 # run-time (that is, during calls to sqlite3_step()).
182 #
183 do_test func3-5.59 {
184 db eval {EXPLAIN SELECT likely(min(1.0+'2.0',4*11))}
185 } [db eval {EXPLAIN SELECT min(1.0+'2.0',4*11)}]
186
187
188
189
71 finish_test 190 finish_test
OLDNEW
« no previous file with comments | « third_party/sqlite/src/test/func.test ('k') | third_party/sqlite/src/test/func4.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698