Mercurial > hg > orthanc
annotate UnitTestsSources/SQLiteTests.cpp @ 1211:88511c737760
integration db-changes->mainline
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 04 Nov 2014 13:57:11 +0100 |
parents | dfc076546821 |
children | 6e7e5ed91c2d |
rev | line source |
---|---|
827
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
1 /** |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
2 * Orthanc - A Lightweight, RESTful DICOM Store |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
3 * Copyright (C) 2012-2014 Medical Physics Department, CHU of Liege, |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
4 * Belgium |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
5 * |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
6 * This program is free software: you can redistribute it and/or |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
7 * modify it under the terms of the GNU General Public License as |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
8 * published by the Free Software Foundation, either version 3 of the |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
9 * License, or (at your option) any later version. |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
10 * |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
11 * In addition, as a special exception, the copyright holders of this |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
12 * program give permission to link the code of its release with the |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
13 * OpenSSL project's "OpenSSL" library (or with modified versions of it |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
14 * that use the same license as the "OpenSSL" library), and distribute |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
15 * the linked executables. You must obey the GNU General Public License |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
16 * in all respects for all of the code used other than "OpenSSL". If you |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
17 * modify file(s) with this exception, you may extend this exception to |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
18 * your version of the file(s), but you are not obligated to do so. If |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
19 * you do not wish to do so, delete this exception statement from your |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
20 * version. If you delete this exception statement from all source files |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
21 * in the program, then also delete it here. |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
22 * |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
23 * This program is distributed in the hope that it will be useful, but |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
24 * WITHOUT ANY WARRANTY; without even the implied warranty of |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
26 * General Public License for more details. |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
27 * |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
28 * You should have received a copy of the GNU General Public License |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
29 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
30 **/ |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
31 |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
32 |
831
84513f2ee1f3
pch for unit tests and server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
827
diff
changeset
|
33 #include "PrecompiledHeadersUnitTests.h" |
0 | 34 #include "gtest/gtest.h" |
35 | |
36 #include "../Core/Toolbox.h" | |
37 #include "../Core/SQLite/Connection.h" | |
38 #include "../Core/SQLite/Statement.h" | |
137
0e97abc7b950
fix of a bug in older versions of sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
39 #include "../Core/SQLite/Transaction.h" |
0 | 40 |
41 #include <sqlite3.h> | |
42 | |
63 | 43 using namespace Orthanc; |
0 | 44 |
45 | |
46 TEST(SQLite, Configuration) | |
47 { | |
48 ASSERT_EQ(1, sqlite3_threadsafe()); | |
49 } | |
50 | |
51 | |
52 TEST(SQLite, Connection) | |
53 { | |
803
4689e400e0fa
directory to store the results of the unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
724
diff
changeset
|
54 Toolbox::RemoveFile("UnitTestsResults/coucou"); |
0 | 55 SQLite::Connection c; |
803
4689e400e0fa
directory to store the results of the unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
724
diff
changeset
|
56 c.Open("UnitTestsResults/coucou"); |
0 | 57 c.Execute("CREATE TABLE c(k INTEGER PRIMARY KEY AUTOINCREMENT, v INTEGER)"); |
58 c.Execute("INSERT INTO c VALUES(NULL, 42);"); | |
59 } | |
60 | |
61 | |
62 TEST(SQLite, StatementReferenceBasic) | |
63 { | |
64 sqlite3* db; | |
65 sqlite3_open(":memory:", &db); | |
66 | |
67 { | |
68 SQLite::StatementReference r(db, "SELECT * FROM sqlite_master"); | |
69 ASSERT_EQ(0u, r.GetReferenceCount()); | |
70 | |
71 { | |
72 SQLite::StatementReference r1(r); | |
73 ASSERT_EQ(1u, r.GetReferenceCount()); | |
74 ASSERT_EQ(0u, r1.GetReferenceCount()); | |
75 | |
76 { | |
77 SQLite::StatementReference r2(r); | |
78 ASSERT_EQ(2u, r.GetReferenceCount()); | |
79 ASSERT_EQ(0u, r1.GetReferenceCount()); | |
80 ASSERT_EQ(0u, r2.GetReferenceCount()); | |
81 | |
82 SQLite::StatementReference r3(r2); | |
83 ASSERT_EQ(3u, r.GetReferenceCount()); | |
84 ASSERT_EQ(0u, r1.GetReferenceCount()); | |
85 ASSERT_EQ(0u, r2.GetReferenceCount()); | |
86 ASSERT_EQ(0u, r3.GetReferenceCount()); | |
87 } | |
88 | |
89 ASSERT_EQ(1u, r.GetReferenceCount()); | |
90 ASSERT_EQ(0u, r1.GetReferenceCount()); | |
91 | |
92 { | |
93 SQLite::StatementReference r2(r); | |
94 ASSERT_EQ(2u, r.GetReferenceCount()); | |
95 ASSERT_EQ(0u, r1.GetReferenceCount()); | |
96 ASSERT_EQ(0u, r2.GetReferenceCount()); | |
97 } | |
98 | |
99 ASSERT_EQ(1u, r.GetReferenceCount()); | |
100 ASSERT_EQ(0u, r1.GetReferenceCount()); | |
101 } | |
102 | |
103 ASSERT_EQ(0u, r.GetReferenceCount()); | |
104 } | |
105 | |
106 sqlite3_close(db); | |
107 } | |
108 | |
109 TEST(SQLite, StatementBasic) | |
110 { | |
111 SQLite::Connection c; | |
112 c.OpenInMemory(); | |
113 | |
114 SQLite::Statement s(c, "SELECT * from sqlite_master"); | |
115 s.Run(); | |
116 | |
117 for (unsigned int i = 0; i < 5; i++) | |
118 { | |
119 SQLite::Statement cs(c, SQLITE_FROM_HERE, "SELECT * from sqlite_master"); | |
120 cs.Step(); | |
121 } | |
122 } | |
123 | |
124 | |
125 namespace | |
126 { | |
127 static bool destroyed; | |
128 | |
129 class MyFunc : public SQLite::IScalarFunction | |
130 { | |
131 public: | |
132 MyFunc() | |
133 { | |
134 destroyed = false; | |
135 } | |
136 | |
137 virtual ~MyFunc() | |
138 { | |
139 destroyed = true; | |
140 } | |
141 | |
142 virtual const char* GetName() const | |
143 { | |
144 return "MYFUNC"; | |
145 } | |
146 | |
147 virtual unsigned int GetCardinality() const | |
148 { | |
149 return 2; | |
150 } | |
151 | |
152 virtual void Compute(SQLite::FunctionContext& context) | |
153 { | |
154 context.SetIntResult(1000 + context.GetIntValue(0) * context.GetIntValue(1)); | |
155 } | |
156 }; | |
157 | |
158 class MyDelete : public SQLite::IScalarFunction | |
159 { | |
160 public: | |
161 std::set<int> deleted_; | |
162 | |
163 virtual const char* GetName() const | |
164 { | |
165 return "MYDELETE"; | |
166 } | |
167 | |
168 virtual unsigned int GetCardinality() const | |
169 { | |
170 return 1; | |
171 } | |
172 | |
173 virtual void Compute(SQLite::FunctionContext& context) | |
174 { | |
175 deleted_.insert(context.GetIntValue(0)); | |
176 context.SetNullResult(); | |
177 } | |
178 }; | |
179 } | |
180 | |
181 TEST(SQLite, ScalarFunction) | |
182 { | |
183 { | |
184 SQLite::Connection c; | |
185 c.OpenInMemory(); | |
186 c.Register(new MyFunc()); | |
187 c.Execute("CREATE TABLE t(id INTEGER PRIMARY KEY, v1 INTEGER, v2 INTEGER);"); | |
188 c.Execute("INSERT INTO t VALUES(NULL, 2, 3);"); | |
189 c.Execute("INSERT INTO t VALUES(NULL, 4, 4);"); | |
190 c.Execute("INSERT INTO t VALUES(NULL, 6, 5);"); | |
191 SQLite::Statement t(c, "SELECT MYFUNC(v1, v2), v1, v2 FROM t"); | |
192 int i = 0; | |
193 while (t.Step()) | |
194 { | |
195 ASSERT_EQ(t.ColumnInt(0), 1000 + t.ColumnInt(1) * t.ColumnInt(2)); | |
196 i++; | |
197 } | |
198 ASSERT_EQ(3, i); | |
199 ASSERT_FALSE(destroyed); | |
200 } | |
201 ASSERT_TRUE(destroyed); | |
202 } | |
203 | |
204 TEST(SQLite, CascadedDeleteCallback) | |
205 { | |
206 SQLite::Connection c; | |
207 c.OpenInMemory(); | |
208 MyDelete *func = new MyDelete(); | |
209 c.Register(func); | |
210 c.Execute("CREATE TABLE parent(id INTEGER PRIMARY KEY, dummy INTEGER);"); | |
211 c.Execute("CREATE TABLE child(" | |
212 " id INTEGER PRIMARY KEY, " | |
213 " parent INTEGER REFERENCES parent(id) ON DELETE CASCADE, " | |
214 " value INTEGER);"); | |
215 c.Execute("CREATE TRIGGER childRemoved " | |
216 "AFTER DELETE ON child " | |
217 "FOR EACH ROW BEGIN " | |
218 " SELECT MYDELETE(old.value); " | |
219 "END;"); | |
220 | |
221 c.Execute("INSERT INTO parent VALUES(42, 100);"); | |
222 c.Execute("INSERT INTO parent VALUES(43, 101);"); | |
223 | |
224 c.Execute("INSERT INTO child VALUES(NULL, 42, 4200);"); | |
225 c.Execute("INSERT INTO child VALUES(NULL, 42, 4201);"); | |
226 | |
227 c.Execute("INSERT INTO child VALUES(NULL, 43, 4300);"); | |
228 c.Execute("INSERT INTO child VALUES(NULL, 43, 4301);"); | |
229 | |
230 // The following command deletes "parent(43, 101)", then in turns | |
231 // "child(NULL, 43, 4300/4301)", then calls the MyDelete on 4300 and | |
232 // 4301 | |
233 c.Execute("DELETE FROM parent WHERE dummy=101"); | |
234 | |
235 ASSERT_EQ(2u, func->deleted_.size()); | |
236 ASSERT_TRUE(func->deleted_.find(4300) != func->deleted_.end()); | |
237 ASSERT_TRUE(func->deleted_.find(4301) != func->deleted_.end()); | |
238 } | |
137
0e97abc7b950
fix of a bug in older versions of sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
239 |
0e97abc7b950
fix of a bug in older versions of sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
240 |
0e97abc7b950
fix of a bug in older versions of sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
241 TEST(SQLite, EmptyTransactions) |
0e97abc7b950
fix of a bug in older versions of sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
242 { |
0e97abc7b950
fix of a bug in older versions of sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
243 try |
0e97abc7b950
fix of a bug in older versions of sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
244 { |
0e97abc7b950
fix of a bug in older versions of sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
245 SQLite::Connection c; |
0e97abc7b950
fix of a bug in older versions of sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
246 c.OpenInMemory(); |
0e97abc7b950
fix of a bug in older versions of sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
247 |
0e97abc7b950
fix of a bug in older versions of sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
248 c.Execute("CREATE TABLE a(id INTEGER PRIMARY KEY);"); |
0e97abc7b950
fix of a bug in older versions of sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
249 c.Execute("INSERT INTO a VALUES(NULL)"); |
0e97abc7b950
fix of a bug in older versions of sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
250 |
0e97abc7b950
fix of a bug in older versions of sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
251 { |
0e97abc7b950
fix of a bug in older versions of sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
252 SQLite::Transaction t(c); |
0e97abc7b950
fix of a bug in older versions of sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
253 t.Begin(); |
0e97abc7b950
fix of a bug in older versions of sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
254 { |
0e97abc7b950
fix of a bug in older versions of sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
255 SQLite::Statement s(c, SQLITE_FROM_HERE, "SELECT * FROM a"); |
0e97abc7b950
fix of a bug in older versions of sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
256 s.Step(); |
0e97abc7b950
fix of a bug in older versions of sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
257 } |
0e97abc7b950
fix of a bug in older versions of sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
258 //t.Commit(); |
0e97abc7b950
fix of a bug in older versions of sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
259 } |
0e97abc7b950
fix of a bug in older versions of sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
260 |
0e97abc7b950
fix of a bug in older versions of sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
261 { |
0e97abc7b950
fix of a bug in older versions of sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
262 SQLite::Statement s(c, SQLITE_FROM_HERE, "SELECT * FROM a"); |
0e97abc7b950
fix of a bug in older versions of sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
263 s.Step(); |
0e97abc7b950
fix of a bug in older versions of sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
264 } |
0e97abc7b950
fix of a bug in older versions of sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
265 } |
0e97abc7b950
fix of a bug in older versions of sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
266 catch (OrthancException& e) |
0e97abc7b950
fix of a bug in older versions of sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
267 { |
0e97abc7b950
fix of a bug in older versions of sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
268 fprintf(stderr, "Exception: [%s]\n", e.What()); |
0e97abc7b950
fix of a bug in older versions of sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
269 throw e; |
0e97abc7b950
fix of a bug in older versions of sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
270 } |
0e97abc7b950
fix of a bug in older versions of sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
271 } |
724 | 272 |
273 | |
274 TEST(SQLite, Types) | |
275 { | |
276 SQLite::Connection c; | |
277 c.OpenInMemory(); | |
278 c.Execute("CREATE TABLE a(id INTEGER PRIMARY KEY, value)"); | |
279 | |
280 { | |
281 SQLite::Statement s(c, std::string("SELECT * FROM a")); | |
282 ASSERT_EQ(2, s.ColumnCount()); | |
283 ASSERT_FALSE(s.Step()); | |
284 } | |
285 | |
286 { | |
287 SQLite::Statement s(c, SQLITE_FROM_HERE, std::string("SELECT * FROM a")); | |
288 ASSERT_FALSE(s.Step()); | |
289 ASSERT_EQ("SELECT * FROM a", s.GetOriginalSQLStatement()); | |
290 } | |
291 | |
292 { | |
293 SQLite::Statement s(c, SQLITE_FROM_HERE, "INSERT INTO a VALUES(NULL, ?);"); | |
294 s.BindNull(0); ASSERT_TRUE(s.Run()); s.Reset(); | |
295 s.BindBool(0, true); ASSERT_TRUE(s.Run()); s.Reset(); | |
296 s.BindInt(0, 42); ASSERT_TRUE(s.Run()); s.Reset(); | |
297 s.BindInt64(0, 42ll); ASSERT_TRUE(s.Run()); s.Reset(); | |
298 s.BindDouble(0, 42.5); ASSERT_TRUE(s.Run()); s.Reset(); | |
299 s.BindCString(0, "Hello"); ASSERT_TRUE(s.Run()); s.Reset(); | |
300 s.BindBlob(0, "Hello", 5); ASSERT_TRUE(s.Run()); s.Reset(); | |
301 } | |
302 | |
303 { | |
304 SQLite::Statement s(c, SQLITE_FROM_HERE, std::string("SELECT * FROM a")); | |
305 ASSERT_TRUE(s.Step()); | |
306 ASSERT_EQ(SQLite::COLUMN_TYPE_NULL, s.GetColumnType(1)); | |
307 ASSERT_TRUE(s.ColumnIsNull(1)); | |
308 ASSERT_TRUE(s.Step()); | |
309 ASSERT_EQ(SQLite::COLUMN_TYPE_INTEGER, s.GetColumnType(1)); | |
310 ASSERT_TRUE(s.ColumnBool(1)); | |
311 ASSERT_TRUE(s.Step()); | |
312 ASSERT_EQ(SQLite::COLUMN_TYPE_INTEGER, s.GetColumnType(1)); | |
313 ASSERT_EQ(42, s.ColumnInt(1)); | |
314 ASSERT_TRUE(s.Step()); | |
315 ASSERT_EQ(SQLite::COLUMN_TYPE_INTEGER, s.GetColumnType(1)); | |
316 ASSERT_EQ(42ll, s.ColumnInt64(1)); | |
317 ASSERT_TRUE(s.Step()); | |
318 ASSERT_EQ(SQLite::COLUMN_TYPE_FLOAT, s.GetColumnType(1)); | |
876 | 319 ASSERT_DOUBLE_EQ(42.5, s.ColumnDouble(1)); |
724 | 320 ASSERT_TRUE(s.Step()); |
321 ASSERT_EQ(SQLite::COLUMN_TYPE_TEXT, s.GetColumnType(1)); | |
322 ASSERT_EQ("Hello", s.ColumnString(1)); | |
323 ASSERT_TRUE(s.Step()); | |
324 ASSERT_EQ(SQLite::COLUMN_TYPE_BLOB, s.GetColumnType(1)); | |
325 ASSERT_EQ(5, s.ColumnByteLength(1)); | |
326 ASSERT_TRUE(!memcmp("Hello", s.ColumnBlob(1), 5)); | |
327 | |
328 std::string t; | |
329 ASSERT_TRUE(s.ColumnBlobAsString(1, &t)); | |
330 ASSERT_EQ("Hello", t); | |
331 | |
332 ASSERT_FALSE(s.Step()); | |
333 } | |
334 } |