Skip to content

Commit

Permalink
WIP tests: alter unit test, and print the version of the system libra…
Browse files Browse the repository at this point in the history
…ry if linking with it, and the path to include dirs
  • Loading branch information
SRombauts committed Aug 18, 2024
1 parent d015229 commit 6a7c0bd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,9 @@ else (SQLITECPP_INTERNAL_SQLITE)
endif()
else()
find_package (SQLite3 REQUIRED)
message(STATUS "Link to sqlite3 system library")
message(STATUS "Link to sqlite3 system library ${SQLite3_VERSION} (${SQLite3_INCLUDE_DIRS})")
# TODO: shouldn't be needed:
include_directories(${SQLite3_INCLUDE_DIRS})
target_link_libraries(SQLiteCpp PUBLIC SQLite::SQLite3)
if(SQLite3_VERSION VERSION_LESS "3.19")
set_target_properties(SQLiteCpp PROPERTIES COMPILE_FLAGS "-DSQLITECPP_HAS_MEM_STRUCT")
Expand Down
2 changes: 1 addition & 1 deletion examples/example1/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ int main()
{
// Using SQLITE_VERSION would require #include <sqlite3.h> which we want to avoid: use SQLite::VERSION if possible.
// std::cout << "SQlite3 version " << SQLITE_VERSION << std::endl;
std::cout << "SQlite3 version " << SQLite::VERSION << " (" << SQLite::getLibVersion() << ")" << std::endl;
std::cout << "SQlite3 compile time header version " << SQLite::VERSION << " (vs dynamic lib version " << SQLite::getLibVersion() << ")" << std::endl;
std::cout << "SQliteC++ version " << SQLITECPP_VERSION << std::endl;

////////////////////////////////////////////////////////////////////////////
Expand Down
12 changes: 9 additions & 3 deletions tests/Database_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ void assertion_failed(const char* apFile, const long apLine, const char* apFunc,
}
#endif

#ifdef SQLITECPP_INTERNAL_SQLITE
// TODO test #ifdef SQLITECPP_INTERNAL_SQLITE
TEST(SQLiteCpp, version)
{
EXPECT_STREQ(SQLITE_VERSION, SQLite::VERSION);
EXPECT_EQ (SQLITE_VERSION_NUMBER, SQLite::VERSION_NUMBER);
EXPECT_STREQ(SQLITE_VERSION, SQLite::getLibVersion());
EXPECT_EQ (SQLITE_VERSION_NUMBER, SQLite::getLibVersionNumber());
}
#endif
// TODO test #endif

TEST(Database, ctorExecCreateDropExist)
{
Expand Down Expand Up @@ -559,7 +559,13 @@ TEST(Database, getHeaderInfo)
EXPECT_EQ(h.databaseTextEncoding, 1);
EXPECT_EQ(h.incrementalVaccumMode, 0);
EXPECT_EQ(h.versionValidFor, 3);
EXPECT_EQ(h.sqliteVersion, SQLITE_VERSION_NUMBER);
// TODO on macOS it seems that the SQLITE_VERSION from sqlite3.h doesn't match the getLibVersion() from the DLL
#if defined(SQLITECPP_INTERNAL_SQLITE) && defined(__APPLE__)
EXPECT_EQ(h.sqliteVersion, static_cast<unsigned long>(SQLite::getLibVersionNumber()));
#else
EXPECT_EQ(h.sqliteVersion, static_cast<unsigned long>(SQLite::getLibVersionNumber()));
EXPECT_EQ(h.sqliteVersion, SQLITE_VERSION_NUMBER);
#endif && !defined(__APPLE__)
}
remove("test.db3");
}
Expand Down

0 comments on commit 6a7c0bd

Please sign in to comment.