From 9fb534a7ca1f434c7bb3ad3ab3454e4c9a561044 Mon Sep 17 00:00:00 2001 From: program-- Date: Mon, 10 Jul 2023 08:00:27 -0700 Subject: [PATCH] rev: remove default construction for sqlite object changes per review at https://github.com/NOAA-OWP/ngen/pull/522#discussion_r1256229575 --- include/geopackage/SQLite.hpp | 2 +- test/geopackage/SQLite_Test.cpp | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/include/geopackage/SQLite.hpp b/include/geopackage/SQLite.hpp index 5e163c3f28..eeccdf103f 100644 --- a/include/geopackage/SQLite.hpp +++ b/include/geopackage/SQLite.hpp @@ -199,7 +199,7 @@ class sqlite stmt_t stmt = nullptr; public: - sqlite() = default; + sqlite() = delete; /** * Construct a new sqlite object from a path to database diff --git a/test/geopackage/SQLite_Test.cpp b/test/geopackage/SQLite_Test.cpp index c1980fe58c..56216ea5a0 100644 --- a/test/geopackage/SQLite_Test.cpp +++ b/test/geopackage/SQLite_Test.cpp @@ -19,32 +19,33 @@ class SQLite_Test : public ::testing::Test if (this->path.empty()) { FAIL() << "can't find gauge_01073000.gpkg"; } - - ASSERT_NO_THROW(this->db = sqlite(this->path)); } void TearDown() override {}; std::string path; - sqlite db; + }; TEST_F(SQLite_Test, sqlite_access_test) { + sqlite db {this->path}; // user wants metadata - EXPECT_TRUE(this->db.has_table("gpkg_contents")); - EXPECT_FALSE(this->db.has_table("some_fake_table")); + EXPECT_TRUE(db.has_table("gpkg_contents")); + EXPECT_FALSE(db.has_table("some_fake_table")); } TEST_F(SQLite_Test, sqlite_query_test) { - if (this->db.connection() == nullptr) { + sqlite db {this->path}; + + if (db.connection() == nullptr) { FAIL() << "database is not loaded"; } // user provides a query const std::string query = "SELECT * FROM gpkg_contents LIMIT 1"; - sqlite_iter iter = this->db.query(query); + sqlite_iter iter = db.query(query); EXPECT_EQ(iter.num_columns(), 10); EXPECT_EQ(iter.columns(), std::vector({