30 #include <gtest/gtest.h>
41 sqlite3* db =
nullptr;
42 ASSERT_EQ(sqlite3_open(
":memory:", &db), SQLITE_OK);
53 const int wrong_schema = 2;
56 const std::string query =
"PRAGMA user_version = " + std::to_string(wrong_schema) +
";";
57 ASSERT_EQ(sqlite3_exec(db_.get(), query.c_str(),
nullptr,
nullptr,
nullptr), SQLITE_OK);
63 FAIL() <<
"connect() didn't throw any exception";
72 FAIL() <<
"connect() threw the wrong exception type";
78 const int default_schema = 0;
79 sqlite3_stmt* stmt =
nullptr;
80 ASSERT_EQ(sqlite3_prepare_v2(db_.get(),
"PRAGMA user_version;", -1, &stmt,
nullptr), SQLITE_OK);
82 ASSERT_EQ(sqlite3_step(stmt), SQLITE_ROW);
83 ASSERT_EQ(sqlite3_column_int(stmt, 0), default_schema);
85 const std::string query =
87 ASSERT_EQ(sqlite3_exec(db_.get(), query.c_str(),
nullptr,
nullptr,
nullptr), SQLITE_OK);
97 ASSERT_NO_THROW(conn.
connect());
101 ASSERT_NO_THROW(conn.
connect());
103 sqlite3_stmt* stmt =
nullptr;
104 ASSERT_EQ(sqlite3_prepare_v2(db_.get(),
"PRAGMA user_version;", -1, &stmt,
nullptr), SQLITE_OK);
106 ASSERT_EQ(sqlite3_step(stmt), SQLITE_ROW);
110 int main(
int argc,
char** argv)
113 ::testing::InitGoogleTest(&argc, argv);
114 return RUN_ALL_TESTS();