Skip to content

Commit

Permalink
core: Add unit test to cover basic SQLite functionalities. (#380)
Browse files Browse the repository at this point in the history
Co-authored-by: kirkrodrigues <2454684+kirkrodrigues@users.noreply.github.com>
  • Loading branch information
LinZhihao-723 and kirkrodrigues authored May 13, 2024
1 parent 9ccefad commit 0611040
Show file tree
Hide file tree
Showing 4 changed files with 430 additions and 0 deletions.
1 change: 1 addition & 0 deletions components/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ set(SOURCE_FILES_unitTest
tests/test-ParserWithUserSchema.cpp
tests/test-query_methods.cpp
tests/test-Segment.cpp
tests/test-SQLiteDB.cpp
tests/test-Stopwatch.cpp
tests/test-StreamingCompression.cpp
tests/test-string_utils.cpp
Expand Down
9 changes: 9 additions & 0 deletions components/core/src/clp/SQLiteDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ void SQLiteDB::open(string const& path) {
}
}

SQLiteDB::~SQLiteDB() {
if (nullptr == m_db_handle) {
return;
}
if (false == close()) {
SPDLOG_WARN("Failed to close underlying SQLite database - this may cause a memory leak.");
}
}

bool SQLiteDB::close() {
auto return_value = sqlite3_close(m_db_handle);
if (SQLITE_BUSY == return_value) {
Expand Down
3 changes: 3 additions & 0 deletions components/core/src/clp/SQLiteDB.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ class SQLiteDB {
// Constructors
SQLiteDB() : m_db_handle(nullptr) {}

// Destructor
~SQLiteDB();

// Methods
void open(std::string const& path);
bool close();
Expand Down
Loading

0 comments on commit 0611040

Please sign in to comment.