Skip to content

Commit 0611040

Browse files
core: Add unit test to cover basic SQLite functionalities. (y-scope#380)
Co-authored-by: kirkrodrigues <[email protected]>
1 parent 9ccefad commit 0611040

File tree

4 files changed

+430
-0
lines changed

4 files changed

+430
-0
lines changed

components/core/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,7 @@ set(SOURCE_FILES_unitTest
431431
tests/test-ParserWithUserSchema.cpp
432432
tests/test-query_methods.cpp
433433
tests/test-Segment.cpp
434+
tests/test-SQLiteDB.cpp
434435
tests/test-Stopwatch.cpp
435436
tests/test-StreamingCompression.cpp
436437
tests/test-string_utils.cpp

components/core/src/clp/SQLiteDB.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@ void SQLiteDB::open(string const& path) {
1919
}
2020
}
2121

22+
SQLiteDB::~SQLiteDB() {
23+
if (nullptr == m_db_handle) {
24+
return;
25+
}
26+
if (false == close()) {
27+
SPDLOG_WARN("Failed to close underlying SQLite database - this may cause a memory leak.");
28+
}
29+
}
30+
2231
bool SQLiteDB::close() {
2332
auto return_value = sqlite3_close(m_db_handle);
2433
if (SQLITE_BUSY == return_value) {

components/core/src/clp/SQLiteDB.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ class SQLiteDB {
2525
// Constructors
2626
SQLiteDB() : m_db_handle(nullptr) {}
2727

28+
// Destructor
29+
~SQLiteDB();
30+
2831
// Methods
2932
void open(std::string const& path);
3033
bool close();

0 commit comments

Comments
 (0)