summaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2023-01-29 13:19:33 +0100
committerRoland Reichwein <mail@reichwein.it>2023-01-29 13:19:33 +0100
commitf7160a063d5dedd9525b306534109b96087f1896 (patch)
treed53dea199a65aaf9ceac8aca75e060444087f963 /tests
parent19c343fc2ea6dbf7eeae3ac7000c5c877ddfec63 (diff)
Add SQL VACUUM to cleanup
Diffstat (limited to 'tests')
-rw-r--r--tests/test-compiledsql.cpp44
1 files changed, 27 insertions, 17 deletions
diff --git a/tests/test-compiledsql.cpp b/tests/test-compiledsql.cpp
index 00a8221..d14220c 100644
--- a/tests/test-compiledsql.cpp
+++ b/tests/test-compiledsql.cpp
@@ -44,23 +44,33 @@ TEST_F(CompiledSQLTest, create)
{
SQLite::Database db{testDbFilename, SQLite::OPEN_READWRITE | SQLite::OPEN_CREATE};
- CompiledSQL stmt1{db};
- stmt1.init("CREATE TABLE documents (id VARCHAR(16) PRIMARY KEY)");
- stmt1.execute();
-
- CompiledSQL stmt2{db};
- stmt2.init("INSERT INTO documents (id) values (?)");
- stmt2.bind(1, "abc");
- ASSERT_TRUE(stmt2.execute());
-
- CompiledSQL stmt3{db};
- stmt3.init("SELECT id FROM documents WHERE id = ?");
- stmt3.bind(1, "abc");
- ASSERT_TRUE(stmt3.execute());
- EXPECT_EQ(stmt3.getColumn<std::string>(0), "abc");
- stmt3.init("SELECT id FROM documents WHERE id = ?");
- stmt3.bind(1, "def");
- ASSERT_FALSE(stmt3.execute());
+ {
+ CompiledSQL stmt1{db, "CREATE TABLE documents (id VARCHAR(16) PRIMARY KEY)"};
+ CompiledSQL::Guard g{stmt1};
+ stmt1.execute();
+ }
+
+ {
+ CompiledSQL stmt2{db, "INSERT INTO documents (id) values (?)"};
+ CompiledSQL::Guard g{stmt2};
+ stmt2.bind(1, "abc");
+ ASSERT_TRUE(stmt2.execute());
+ }
+
+ {
+ CompiledSQL stmt3{db, "SELECT id FROM documents WHERE id = ?"};
+ CompiledSQL::Guard g{stmt3};
+ stmt3.bind(1, "abc");
+ ASSERT_TRUE(stmt3.execute());
+ EXPECT_EQ(stmt3.getColumn<std::string>(0), "abc");
+ }
+
+ {
+ CompiledSQL stmt4{db, "SELECT id FROM documents WHERE id = ?"};
+ CompiledSQL::Guard g{stmt4};
+ stmt4.bind(1, "def");
+ ASSERT_FALSE(stmt4.execute());
+ }
EXPECT_TRUE(fs::exists(testDbFilename));
}