summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2017-01-04 11:09:45 -0400
committerBruno de Oliveira Abinader <bruno@mapbox.com>2017-01-23 19:06:53 +0200
commit80d72123dfe3cb9f560b6a150a998eeda480b9de (patch)
treef002717a45c7179e66b02c630b94eca5dbb5f047 /test
parent97b433edc99f5b7212915aab483e119f60fde101 (diff)
downloadqtlocation-mapboxgl-80d72123dfe3cb9f560b6a150a998eeda480b9de.tar.gz
[core] Move lastInsertRowId/changes to sqlite::Statement
Diffstat (limited to 'test')
-rw-r--r--test/storage/offline_database.test.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/storage/offline_database.test.cpp b/test/storage/offline_database.test.cpp
index 2e25835d80..5e8da106da 100644
--- a/test/storage/offline_database.test.cpp
+++ b/test/storage/offline_database.test.cpp
@@ -80,6 +80,25 @@ private:
} // namespace
+TEST(OfflineDatabase, Statement) {
+ using namespace mbgl;
+
+ mapbox::sqlite::Database db(":memory:", mapbox::sqlite::ReadWrite | mapbox::sqlite::Create);
+ db.exec("CREATE TABLE test (id INTEGER)");
+ mapbox::sqlite::Statement stmt1 = db.prepare("INSERT INTO test (id) VALUES (?1)");
+ stmt1.bind(1, 0);
+ stmt1.run();
+ ASSERT_EQ(stmt1.lastInsertRowId(), 1);
+ ASSERT_EQ(stmt1.changes(), 1);
+
+ mapbox::sqlite::Statement stmt2 = db.prepare("INSERT INTO test (id) VALUES (?1)");
+ stmt2.bind(1, 0);
+ stmt2.run();
+ ASSERT_EQ(stmt1.lastInsertRowId(), 1);
+ ASSERT_EQ(stmt2.lastInsertRowId(), 2);
+ ASSERT_EQ(stmt2.changes(), 1);
+}
+
TEST(OfflineDatabase, TEST_REQUIRES_WRITE(Create)) {
using namespace mbgl;