comparison UnitTests/SQLite.cpp @ 137:0e97abc7b950

fix of a bug in older versions of sqlite
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 10 Oct 2012 13:13:14 +0200
parents f1d0470ff334
children
comparison
equal deleted inserted replaced
136:fe180eae201d 137:0e97abc7b950
1 #include "gtest/gtest.h" 1 #include "gtest/gtest.h"
2 2
3 #include "../Core/Toolbox.h" 3 #include "../Core/Toolbox.h"
4 #include "../Core/SQLite/Connection.h" 4 #include "../Core/SQLite/Connection.h"
5 #include "../Core/SQLite/Statement.h" 5 #include "../Core/SQLite/Statement.h"
6 #include "../Core/SQLite/Transaction.h"
6 7
7 #include <sqlite3.h> 8 #include <sqlite3.h>
8 9
9 using namespace Orthanc; 10 using namespace Orthanc;
10 11
200 201
201 ASSERT_EQ(2u, func->deleted_.size()); 202 ASSERT_EQ(2u, func->deleted_.size());
202 ASSERT_TRUE(func->deleted_.find(4300) != func->deleted_.end()); 203 ASSERT_TRUE(func->deleted_.find(4300) != func->deleted_.end());
203 ASSERT_TRUE(func->deleted_.find(4301) != func->deleted_.end()); 204 ASSERT_TRUE(func->deleted_.find(4301) != func->deleted_.end());
204 } 205 }
206
207
208 TEST(SQLite, EmptyTransactions)
209 {
210 try
211 {
212 SQLite::Connection c;
213 c.OpenInMemory();
214
215 c.Execute("CREATE TABLE a(id INTEGER PRIMARY KEY);");
216 c.Execute("INSERT INTO a VALUES(NULL)");
217
218 {
219 SQLite::Transaction t(c);
220 t.Begin();
221 {
222 SQLite::Statement s(c, SQLITE_FROM_HERE, "SELECT * FROM a");
223 s.Step();
224 }
225 //t.Commit();
226 }
227
228 {
229 SQLite::Statement s(c, SQLITE_FROM_HERE, "SELECT * FROM a");
230 s.Step();
231 }
232 }
233 catch (OrthancException& e)
234 {
235 fprintf(stderr, "Exception: [%s]\n", e.What());
236 throw e;
237 }
238 }