@@ -11,8 +11,8 @@ TEST(SQLite, Statement) {
|
||||
mapbox::sqlite::Database db = mapbox::sqlite::Database::open(":memory:", mapbox::sqlite::ReadWriteCreate);
|
||||
db.exec("CREATE TABLE test (id INTEGER);");
|
||||
|
||||
mapbox::sqlite::Statement stmt1{ db, "INSERT INTO test (id) VALUES (?1);" };
|
||||
mapbox::sqlite::Query query1{ stmt1 };
|
||||
mapbox::sqlite::Statement stmt1{db, "INSERT INTO test (id) VALUES (?1);"};
|
||||
mapbox::sqlite::Query query1{stmt1};
|
||||
ASSERT_EQ(query1.lastInsertRowId(), 0);
|
||||
ASSERT_EQ(query1.changes(), 0u);
|
||||
query1.bind(1, 10);
|
||||
@@ -20,8 +20,8 @@ TEST(SQLite, Statement) {
|
||||
ASSERT_EQ(query1.lastInsertRowId(), 1);
|
||||
ASSERT_EQ(query1.changes(), 1u);
|
||||
|
||||
mapbox::sqlite::Statement stmt2{ db, "INSERT INTO test (id) VALUES (?1);" };
|
||||
mapbox::sqlite::Query query2{ stmt2 };
|
||||
mapbox::sqlite::Statement stmt2{db, "INSERT INTO test (id) VALUES (?1);"};
|
||||
mapbox::sqlite::Query query2{stmt2};
|
||||
ASSERT_EQ(query2.lastInsertRowId(), 0);
|
||||
ASSERT_EQ(query2.changes(), 0u);
|
||||
query2.bind(1, 20);
|
||||
@@ -35,24 +35,24 @@ TEST(SQLite, TEST_REQUIRES_WRITE(TryOpen)) {
|
||||
|
||||
// Should return a CANTOPEN exception when the database doesn't exist,
|
||||
// make sure all the backends behave the same way.
|
||||
auto result = mapbox::sqlite::Database::tryOpen("test/fixtures/offline_database/foobar123.db", mapbox::sqlite::ReadOnly);
|
||||
auto result = mapbox::sqlite::Database::tryOpen("test/fixtures/offline_database/foobar123.db",
|
||||
mapbox::sqlite::ReadOnly);
|
||||
ASSERT_TRUE(result.is<mapbox::sqlite::Exception>());
|
||||
ASSERT_EQ(result.get<mapbox::sqlite::Exception>().code, mapbox::sqlite::ResultCode::CantOpen);
|
||||
EXPECT_EQ(0u, log.uncheckedCount());
|
||||
}
|
||||
|
||||
TEST(SQLite, CloseDatabaseWithPendingTransaction) {
|
||||
auto db = std::make_unique<mapbox::sqlite::Database>(mapbox::sqlite::Database::open(
|
||||
":memory:", mapbox::sqlite::ReadWriteCreate));
|
||||
auto db = std::make_unique<mapbox::sqlite::Database>(
|
||||
mapbox::sqlite::Database::open(":memory:", mapbox::sqlite::ReadWriteCreate));
|
||||
mapbox::sqlite::Transaction transaction(*db);
|
||||
transaction.commit();
|
||||
}
|
||||
|
||||
TEST(SQLite, CloseMovedDatabaseWithPendingTransaction) {
|
||||
// Verifies that we can correctly commit a transaction even if we move the Database object to
|
||||
// another address.
|
||||
auto db1 = mapbox::sqlite::Database::open(":memory:",
|
||||
mapbox::sqlite::ReadWriteCreate);
|
||||
// Verifies that we can correctly commit a transaction even if we move the
|
||||
// Database object to another address.
|
||||
auto db1 = mapbox::sqlite::Database::open(":memory:", mapbox::sqlite::ReadWriteCreate);
|
||||
std::unique_ptr<mapbox::sqlite::Database> db2;
|
||||
mapbox::sqlite::Transaction transaction(db1);
|
||||
db2 = std::make_unique<mapbox::sqlite::Database>(std::move(db1));
|
||||
|
||||
Reference in New Issue
Block a user