diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2018-02-06 17:55:50 +0100 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2018-03-02 11:34:59 +0100 |
commit | c1b548bcfb5339250441fb746333cd2c3c186857 (patch) | |
tree | a6b4158ce6eb0d1a7ff89c169ff7502ff397a304 /test/storage/sqlite.test.cpp | |
parent | 26a435a25489aac9e19b89fd3d93b800dd7721eb (diff) | |
download | qtlocation-mapboxgl-upstream/sqlite-refactor.tar.gz |
[core, qt] move self-resetting Statement/Query object to shared headerupstream/sqlite-refactor
Diffstat (limited to 'test/storage/sqlite.test.cpp')
-rw-r--r-- | test/storage/sqlite.test.cpp | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/test/storage/sqlite.test.cpp b/test/storage/sqlite.test.cpp index 7f33174c0d..918200181f 100644 --- a/test/storage/sqlite.test.cpp +++ b/test/storage/sqlite.test.cpp @@ -9,21 +9,23 @@ TEST(SQLite, Statement) { mapbox::sqlite::Database db(":memory:", mapbox::sqlite::Create | mapbox::sqlite::ReadWrite); db.exec("CREATE TABLE test (id INTEGER);"); - mapbox::sqlite::Statement stmt1 = db.prepare("INSERT INTO test (id) VALUES (?1);"); - ASSERT_EQ(stmt1.lastInsertRowId(), 0); - ASSERT_EQ(stmt1.changes(), 0u); - stmt1.bind(1, 10); - stmt1.run(); - ASSERT_EQ(stmt1.lastInsertRowId(), 1); - ASSERT_EQ(stmt1.changes(), 1u); + 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); + query1.run(); + ASSERT_EQ(query1.lastInsertRowId(), 1); + ASSERT_EQ(query1.changes(), 1u); - mapbox::sqlite::Statement stmt2 = db.prepare("INSERT INTO test (id) VALUES (?1);"); - ASSERT_EQ(stmt2.lastInsertRowId(), 0); - ASSERT_EQ(stmt2.changes(), 0u); - stmt2.bind(1, 20); - stmt2.run(); - ASSERT_EQ(stmt2.lastInsertRowId(), 2); - ASSERT_EQ(stmt2.changes(), 1u); + 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); + query2.run(); + ASSERT_EQ(query2.lastInsertRowId(), 2); + ASSERT_EQ(query2.changes(), 1u); } TEST(SQLite, TEST_REQUIRES_WRITE(CantOpenException)) { |