Mercurial > hg > orthanc
annotate OrthancFramework/UnitTestsSources/SQLiteTests.cpp @ 4142:0ea450e1f0ea
"/series/.../ordered-slices" supports spaces in Image Position/Orientation Patient tags
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 13 Aug 2020 17:44:39 +0200 |
parents | bf7b9edf6b81 |
children | d9473bd5ed43 |
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 |
1900 | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
1288
6e7e5ed91c2d
upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
967
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
3640
94f4a18a79cc
upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
827
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
6 * |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
8 * modify it under the terms of the GNU Lesser General Public License |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
9 * as published by the Free Software Foundation, either version 3 of |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
10 * the License, or (at your option) any later version. |
827
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
11 * |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
12 * 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
|
13 * 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
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
15 * Lesser General Public License for more details. |
827
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
16 * |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
17 * You should have received a copy of the GNU Lesser General Public |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
18 * License along with this program. If not, see |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
19 * <http://www.gnu.org/licenses/>. |
827
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
20 **/ |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
21 |
3d6f9b7d0add
precompiled headers in unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
803
diff
changeset
|
22 |
3992
f9863630ec7f
working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
23 #if ORTHANC_UNIT_TESTS_LINK_FRAMEWORK == 1 |
4063
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4062
diff
changeset
|
24 // Must be the first to be sure to use the Orthanc framework shared library |
4014
27628b0f6ada
merging logging code for plugins and files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3992
diff
changeset
|
25 # include <OrthancFramework.h> |
3992
f9863630ec7f
working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
26 #endif |
f9863630ec7f
working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
27 |
4062 | 28 #include <gtest/gtest.h> |
0 | 29 |
4045 | 30 #include "../Sources/SystemToolbox.h" |
31 #include "../Sources/SQLite/Connection.h" | |
32 #include "../Sources/SQLite/Statement.h" | |
33 #include "../Sources/SQLite/Transaction.h" | |
0 | 34 |
35 #include <sqlite3.h> | |
36 | |
63 | 37 using namespace Orthanc; |
0 | 38 |
39 | |
40 TEST(SQLite, Configuration) | |
41 { | |
1476 | 42 /** |
43 * The system-wide version of SQLite under OS X uses | |
44 * SQLITE_THREADSAFE==2 (SQLITE_CONFIG_SERIALIZED), whereas the | |
45 * static builds of Orthanc use SQLITE_THREADSAFE==1 | |
46 * (SQLITE_CONFIG_MULTITHREAD). In any case, we wish to ensure that | |
47 * SQLITE_THREADSAFE!=0 (SQLITE_CONFIG_SINGLETHREAD). | |
48 **/ | |
49 ASSERT_NE(0, sqlite3_threadsafe()); | |
0 | 50 } |
51 | |
52 | |
53 TEST(SQLite, Connection) | |
54 { | |
2140 | 55 SystemToolbox::RemoveFile("UnitTestsResults/coucou"); |
0 | 56 SQLite::Connection c; |
803
4689e400e0fa
directory to store the results of the unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
724
diff
changeset
|
57 c.Open("UnitTestsResults/coucou"); |
0 | 58 c.Execute("CREATE TABLE c(k INTEGER PRIMARY KEY AUTOINCREMENT, v INTEGER)"); |
59 c.Execute("INSERT INTO c VALUES(NULL, 42);"); | |
60 } | |
61 | |
62 | |
63 TEST(SQLite, StatementReferenceBasic) | |
64 { | |
65 sqlite3* db; | |
66 sqlite3_open(":memory:", &db); | |
67 | |
68 { | |
69 SQLite::StatementReference r(db, "SELECT * FROM sqlite_master"); | |
70 ASSERT_EQ(0u, r.GetReferenceCount()); | |
71 | |
72 { | |
73 SQLite::StatementReference r1(r); | |
74 ASSERT_EQ(1u, r.GetReferenceCount()); | |
75 ASSERT_EQ(0u, r1.GetReferenceCount()); | |
76 | |
77 { | |
78 SQLite::StatementReference r2(r); | |
79 ASSERT_EQ(2u, r.GetReferenceCount()); | |
80 ASSERT_EQ(0u, r1.GetReferenceCount()); | |
81 ASSERT_EQ(0u, r2.GetReferenceCount()); | |
82 | |
83 SQLite::StatementReference r3(r2); | |
84 ASSERT_EQ(3u, r.GetReferenceCount()); | |
85 ASSERT_EQ(0u, r1.GetReferenceCount()); | |
86 ASSERT_EQ(0u, r2.GetReferenceCount()); | |
87 ASSERT_EQ(0u, r3.GetReferenceCount()); | |
88 } | |
89 | |
90 ASSERT_EQ(1u, r.GetReferenceCount()); | |
91 ASSERT_EQ(0u, r1.GetReferenceCount()); | |
92 | |
93 { | |
94 SQLite::StatementReference r2(r); | |
95 ASSERT_EQ(2u, r.GetReferenceCount()); | |
96 ASSERT_EQ(0u, r1.GetReferenceCount()); | |
97 ASSERT_EQ(0u, r2.GetReferenceCount()); | |
98 } | |
99 | |
100 ASSERT_EQ(1u, r.GetReferenceCount()); | |
101 ASSERT_EQ(0u, r1.GetReferenceCount()); | |
102 } | |
103 | |
104 ASSERT_EQ(0u, r.GetReferenceCount()); | |
105 } | |
106 | |
107 sqlite3_close(db); | |
108 } | |
109 | |
110 TEST(SQLite, StatementBasic) | |
111 { | |
112 SQLite::Connection c; | |
113 c.OpenInMemory(); | |
114 | |
115 SQLite::Statement s(c, "SELECT * from sqlite_master"); | |
116 s.Run(); | |
117 | |
118 for (unsigned int i = 0; i < 5; i++) | |
119 { | |
120 SQLite::Statement cs(c, SQLITE_FROM_HERE, "SELECT * from sqlite_master"); | |
121 cs.Step(); | |
122 } | |
123 } | |
124 | |
125 | |
126 namespace | |
127 { | |
128 static bool destroyed; | |
129 | |
130 class MyFunc : public SQLite::IScalarFunction | |
131 { | |
132 public: | |
133 MyFunc() | |
134 { | |
135 destroyed = false; | |
136 } | |
137 | |
2924
22524fd06225
macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
138 virtual ~MyFunc() ORTHANC_OVERRIDE |
0 | 139 { |
140 destroyed = true; | |
141 } | |
142 | |
2924
22524fd06225
macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
143 virtual const char* GetName() const ORTHANC_OVERRIDE |
0 | 144 { |
145 return "MYFUNC"; | |
146 } | |
147 | |
2924
22524fd06225
macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
148 virtual unsigned int GetCardinality() const ORTHANC_OVERRIDE |
0 | 149 { |
150 return 2; | |
151 } | |
152 | |
2924
22524fd06225
macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
153 virtual void Compute(SQLite::FunctionContext& context) ORTHANC_OVERRIDE |
0 | 154 { |
155 context.SetIntResult(1000 + context.GetIntValue(0) * context.GetIntValue(1)); | |
156 } | |
157 }; | |
158 | |
159 class MyDelete : public SQLite::IScalarFunction | |
160 { | |
161 public: | |
162 std::set<int> deleted_; | |
163 | |
2924
22524fd06225
macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
164 virtual const char* GetName() const ORTHANC_OVERRIDE |
0 | 165 { |
166 return "MYDELETE"; | |
167 } | |
168 | |
2924
22524fd06225
macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
169 virtual unsigned int GetCardinality() const ORTHANC_OVERRIDE |
0 | 170 { |
171 return 1; | |
172 } | |
173 | |
2924
22524fd06225
macros ORTHANC_OVERRIDE and ORTHANC_FINAL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
174 virtual void Compute(SQLite::FunctionContext& context) ORTHANC_OVERRIDE |
0 | 175 { |
176 deleted_.insert(context.GetIntValue(0)); | |
177 context.SetNullResult(); | |
178 } | |
179 }; | |
180 } | |
181 | |
182 TEST(SQLite, ScalarFunction) | |
183 { | |
184 { | |
185 SQLite::Connection c; | |
186 c.OpenInMemory(); | |
187 c.Register(new MyFunc()); | |
188 c.Execute("CREATE TABLE t(id INTEGER PRIMARY KEY, v1 INTEGER, v2 INTEGER);"); | |
189 c.Execute("INSERT INTO t VALUES(NULL, 2, 3);"); | |
190 c.Execute("INSERT INTO t VALUES(NULL, 4, 4);"); | |
191 c.Execute("INSERT INTO t VALUES(NULL, 6, 5);"); | |
192 SQLite::Statement t(c, "SELECT MYFUNC(v1, v2), v1, v2 FROM t"); | |
193 int i = 0; | |
194 while (t.Step()) | |
195 { | |
196 ASSERT_EQ(t.ColumnInt(0), 1000 + t.ColumnInt(1) * t.ColumnInt(2)); | |
197 i++; | |
198 } | |
199 ASSERT_EQ(3, i); | |
200 ASSERT_FALSE(destroyed); | |
201 } | |
202 ASSERT_TRUE(destroyed); | |
203 } | |
204 | |
205 TEST(SQLite, CascadedDeleteCallback) | |
206 { | |
207 SQLite::Connection c; | |
208 c.OpenInMemory(); | |
209 MyDelete *func = new MyDelete(); | |
210 c.Register(func); | |
211 c.Execute("CREATE TABLE parent(id INTEGER PRIMARY KEY, dummy INTEGER);"); | |
212 c.Execute("CREATE TABLE child(" | |
213 " id INTEGER PRIMARY KEY, " | |
214 " parent INTEGER REFERENCES parent(id) ON DELETE CASCADE, " | |
215 " value INTEGER);"); | |
216 c.Execute("CREATE TRIGGER childRemoved " | |
217 "AFTER DELETE ON child " | |
218 "FOR EACH ROW BEGIN " | |
219 " SELECT MYDELETE(old.value); " | |
220 "END;"); | |
221 | |
222 c.Execute("INSERT INTO parent VALUES(42, 100);"); | |
223 c.Execute("INSERT INTO parent VALUES(43, 101);"); | |
224 | |
225 c.Execute("INSERT INTO child VALUES(NULL, 42, 4200);"); | |
226 c.Execute("INSERT INTO child VALUES(NULL, 42, 4201);"); | |
227 | |
228 c.Execute("INSERT INTO child VALUES(NULL, 43, 4300);"); | |
229 c.Execute("INSERT INTO child VALUES(NULL, 43, 4301);"); | |
230 | |
231 // The following command deletes "parent(43, 101)", then in turns | |
232 // "child(NULL, 43, 4300/4301)", then calls the MyDelete on 4300 and | |
233 // 4301 | |
234 c.Execute("DELETE FROM parent WHERE dummy=101"); | |
235 | |
236 ASSERT_EQ(2u, func->deleted_.size()); | |
237 ASSERT_TRUE(func->deleted_.find(4300) != func->deleted_.end()); | |
238 ASSERT_TRUE(func->deleted_.find(4301) != func->deleted_.end()); | |
239 } | |
137
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 |
0e97abc7b950
fix of a bug in older versions of sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
242 TEST(SQLite, EmptyTransactions) |
0e97abc7b950
fix of a bug in older versions of sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
243 { |
0e97abc7b950
fix of a bug in older versions of sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
244 try |
0e97abc7b950
fix of a bug in older versions of sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
245 { |
0e97abc7b950
fix of a bug in older versions of sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
246 SQLite::Connection c; |
0e97abc7b950
fix of a bug in older versions of sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
247 c.OpenInMemory(); |
0e97abc7b950
fix of a bug in older versions of sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
248 |
0e97abc7b950
fix of a bug in older versions of sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
249 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
|
250 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
|
251 |
0e97abc7b950
fix of a bug in older versions of sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
252 { |
0e97abc7b950
fix of a bug in older versions of sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
253 SQLite::Transaction t(c); |
0e97abc7b950
fix of a bug in older versions of sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
254 t.Begin(); |
0e97abc7b950
fix of a bug in older versions of sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
255 { |
0e97abc7b950
fix of a bug in older versions of sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
256 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
|
257 s.Step(); |
0e97abc7b950
fix of a bug in older versions of sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
258 } |
0e97abc7b950
fix of a bug in older versions of sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
259 //t.Commit(); |
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 { |
0e97abc7b950
fix of a bug in older versions of sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
263 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
|
264 s.Step(); |
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 } |
0e97abc7b950
fix of a bug in older versions of sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
267 catch (OrthancException& e) |
0e97abc7b950
fix of a bug in older versions of sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
268 { |
0e97abc7b950
fix of a bug in older versions of sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
269 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
|
270 throw e; |
0e97abc7b950
fix of a bug in older versions of sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
271 } |
0e97abc7b950
fix of a bug in older versions of sqlite
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
63
diff
changeset
|
272 } |
724 | 273 |
274 | |
275 TEST(SQLite, Types) | |
276 { | |
277 SQLite::Connection c; | |
278 c.OpenInMemory(); | |
279 c.Execute("CREATE TABLE a(id INTEGER PRIMARY KEY, value)"); | |
280 | |
281 { | |
282 SQLite::Statement s(c, std::string("SELECT * FROM a")); | |
283 ASSERT_EQ(2, s.ColumnCount()); | |
284 ASSERT_FALSE(s.Step()); | |
285 } | |
286 | |
287 { | |
288 SQLite::Statement s(c, SQLITE_FROM_HERE, std::string("SELECT * FROM a")); | |
289 ASSERT_FALSE(s.Step()); | |
290 ASSERT_EQ("SELECT * FROM a", s.GetOriginalSQLStatement()); | |
291 } | |
292 | |
293 { | |
294 SQLite::Statement s(c, SQLITE_FROM_HERE, "INSERT INTO a VALUES(NULL, ?);"); | |
295 s.BindNull(0); ASSERT_TRUE(s.Run()); s.Reset(); | |
296 s.BindBool(0, true); ASSERT_TRUE(s.Run()); s.Reset(); | |
297 s.BindInt(0, 42); ASSERT_TRUE(s.Run()); s.Reset(); | |
298 s.BindInt64(0, 42ll); ASSERT_TRUE(s.Run()); s.Reset(); | |
299 s.BindDouble(0, 42.5); ASSERT_TRUE(s.Run()); s.Reset(); | |
300 s.BindCString(0, "Hello"); ASSERT_TRUE(s.Run()); s.Reset(); | |
301 s.BindBlob(0, "Hello", 5); ASSERT_TRUE(s.Run()); s.Reset(); | |
302 } | |
303 | |
304 { | |
305 SQLite::Statement s(c, SQLITE_FROM_HERE, std::string("SELECT * FROM a")); | |
306 ASSERT_TRUE(s.Step()); | |
307 ASSERT_EQ(SQLite::COLUMN_TYPE_NULL, s.GetColumnType(1)); | |
308 ASSERT_TRUE(s.ColumnIsNull(1)); | |
309 ASSERT_TRUE(s.Step()); | |
310 ASSERT_EQ(SQLite::COLUMN_TYPE_INTEGER, s.GetColumnType(1)); | |
311 ASSERT_TRUE(s.ColumnBool(1)); | |
312 ASSERT_TRUE(s.Step()); | |
313 ASSERT_EQ(SQLite::COLUMN_TYPE_INTEGER, s.GetColumnType(1)); | |
314 ASSERT_EQ(42, s.ColumnInt(1)); | |
315 ASSERT_TRUE(s.Step()); | |
316 ASSERT_EQ(SQLite::COLUMN_TYPE_INTEGER, s.GetColumnType(1)); | |
317 ASSERT_EQ(42ll, s.ColumnInt64(1)); | |
318 ASSERT_TRUE(s.Step()); | |
319 ASSERT_EQ(SQLite::COLUMN_TYPE_FLOAT, s.GetColumnType(1)); | |
876 | 320 ASSERT_DOUBLE_EQ(42.5, s.ColumnDouble(1)); |
724 | 321 ASSERT_TRUE(s.Step()); |
322 ASSERT_EQ(SQLite::COLUMN_TYPE_TEXT, s.GetColumnType(1)); | |
323 ASSERT_EQ("Hello", s.ColumnString(1)); | |
324 ASSERT_TRUE(s.Step()); | |
325 ASSERT_EQ(SQLite::COLUMN_TYPE_BLOB, s.GetColumnType(1)); | |
326 ASSERT_EQ(5, s.ColumnByteLength(1)); | |
327 ASSERT_TRUE(!memcmp("Hello", s.ColumnBlob(1), 5)); | |
328 | |
329 std::string t; | |
330 ASSERT_TRUE(s.ColumnBlobAsString(1, &t)); | |
331 ASSERT_EQ("Hello", t); | |
332 | |
333 ASSERT_FALSE(s.Step()); | |
334 } | |
335 } |