194
void SQLiteTest::testInsertCharPointer()
196
Session tmp (SessionFactory::instance().create(SQLite::Connector::KEY, "dummy.db"));
197
std::string tableName("Person");
198
std::string lastName("lastname");
199
std::string firstName("firstname");
200
std::string address("Address");
204
tmp << "DROP TABLE IF EXISTS Person", now;
205
tmp << "CREATE TABLE IF NOT EXISTS Person (LastName VARCHAR(30), FirstName VARCHAR, Address VARCHAR, Age INTEGER(3))", now;
207
tmp << "INSERT INTO PERSON VALUES(:ln, :fn, :ad, :age)", use("lastname"), use("firstname"), use("Address"), use(133132), now;
208
tmp << "SELECT COUNT(*) FROM PERSON", into(count), now;
210
tmp << "SELECT LastName FROM PERSON", into(result), now;
211
assert (lastName == result);
212
tmp << "SELECT Age FROM PERSON", into(count), now;
213
assert (count == age);
218
void SQLiteTest::testInsertCharPointer2()
220
Session tmp (SessionFactory::instance().create(SQLite::Connector::KEY, "dummy.db"));
221
std::string tableName("Person");
222
std::string lastName("lastname");
223
std::string firstName("firstname");
224
std::string address("Address");
228
tmp << "DROP TABLE IF EXISTS Person", now;
229
tmp << "CREATE TABLE IF NOT EXISTS Person (LastName VARCHAR(30), FirstName VARCHAR, Address VARCHAR, Age INTEGER(3))", now;
231
tmp << "INSERT INTO PERSON VALUES(:ln, :fn, :ad, :age)", use("lastname"), use("firstname"), use("Address"), use(133132), now;
232
tmp << "SELECT COUNT(*) FROM PERSON", into(count), now;
234
Statement stmt1 = (tmp << "SELECT LastName FROM PERSON", into(result));
236
assert (lastName == result);
238
Statement stmt2 = (tmp << "SELECT Age FROM PERSON", into(count));
240
assert (count == age);
244
195
void SQLiteTest::testComplexType()
246
197
Session tmp (SessionFactory::instance().create(SQLite::Connector::KEY, "dummy.db"));
422
372
tmp << "INSERT INTO Strings VALUES(:str)", use(data), now;
424
374
std::vector<int> retData;
425
375
tmp << "SELECT * FROM Strings", into(retData), limit(50), now;
426
376
assert (retData.size() == 50);
445
395
tmp << "INSERT INTO Strings VALUES(:str)", use(data), now;
447
397
std::vector<int> retData;
448
398
tmp << "SELECT * FROM Strings", into(retData), limit(0), now; // stupid test, but at least we shouldn't crash
449
399
assert (retData.size() == 0);
1530
void SQLiteTest::testBindingCount()
1532
Session tmp (SQLite::Connector::KEY, "dummy.db");
1534
tmp << "DROP TABLE IF EXISTS Ints", now;
1535
tmp << "CREATE TABLE Ints (int0 INTEGER)", now;
1538
try { tmp << "INSERT INTO Ints VALUES (?)", now; }
1539
catch (ParameterCountMismatchException&) { }
1541
try { tmp << "INSERT INTO Ints VALUES (?)", use(i), use(i), now; }
1542
catch (ParameterCountMismatchException&) { }
1543
tmp << "INSERT INTO Ints VALUES (?)", use(i), now;
1546
try { tmp << "SELECT int0 from Ints where int0 = ?", into(i), now; }
1547
catch (ParameterCountMismatchException&) { }
1548
tmp << "SELECT int0 from Ints where int0 = ?", use(i), into(j), now;
1580
1553
void SQLiteTest::setUp()
1592
1565
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("SQLiteTest");
1594
1567
CppUnit_addTest(pSuite, SQLiteTest, testSimpleAccess);
1595
CppUnit_addTest(pSuite, SQLiteTest, testInsertCharPointer);
1596
CppUnit_addTest(pSuite, SQLiteTest, testInsertCharPointer2);
1597
1568
CppUnit_addTest(pSuite, SQLiteTest, testComplexType);
1598
1569
CppUnit_addTest(pSuite, SQLiteTest, testSimpleAccessVector);
1599
1570
CppUnit_addTest(pSuite, SQLiteTest, testComplexTypeVector);
1648
1619
CppUnit_addTest(pSuite, SQLiteTest, testTuple1);
1649
1620
CppUnit_addTest(pSuite, SQLiteTest, testTupleVector1);
1650
1621
CppUnit_addTest(pSuite, SQLiteTest, testInternalExtraction);
1622
CppUnit_addTest(pSuite, SQLiteTest, testBindingCount);