Skip to content

Commit

Permalink
rev: remove default construction for sqlite object
Browse files Browse the repository at this point in the history
changes per review at #522 (comment)
  • Loading branch information
program-- authored and mattw-nws committed Jul 18, 2023
1 parent eeccc3a commit 9fb534a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion include/geopackage/SQLite.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 8 additions & 7 deletions test/geopackage/SQLite_Test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string>({
Expand Down

0 comments on commit 9fb534a

Please sign in to comment.