-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…at-version feat: #1606 Better support for FileFormatVersion
- Loading branch information
Showing
7 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
|
||
#include <filesystem> | ||
|
||
#include <osmscout/db/Database.h> | ||
#include <osmscout/TypeConfig.h> | ||
|
||
#include <TestMain.h> | ||
|
||
static std::string GetTestDatabaseDirectory() | ||
{ | ||
char* testsTopDirEnv=::getenv("TESTS_TOP_DIR"); | ||
|
||
if (testsTopDirEnv==nullptr) { | ||
throw osmscout::UninitializedException("Expected environment variable 'TESTS_TOP_DIR' not set"); | ||
} | ||
|
||
std::string testsTopDir=testsTopDirEnv; | ||
|
||
if (testsTopDir.empty()) { | ||
throw osmscout::UninitializedException("Environment variable 'TESTS_TOP_DIR' is empty"); | ||
} | ||
|
||
if (!osmscout::IsDirectory(testsTopDir)) { | ||
throw osmscout::UninitializedException("Environment variable 'TESTS_TOP_DIR' does not point to directory"); | ||
} | ||
|
||
return std::filesystem::path(testsTopDir).append("data").append("testregion").string(); | ||
} | ||
|
||
TEST_CASE("TypeConfig::GetFileFormatVersion(dir) throws exception on missing db") { | ||
CHECK_THROWS_AS(osmscout::TypeConfig::GetDatabaseFileFormatVersion("does_not_exist"),osmscout::IOException); | ||
} | ||
|
||
TEST_CASE("Database::GetFileFormatVersion(dir) throws exception on missing db") { | ||
CHECK_THROWS_AS(osmscout::Database::GetDatabaseFileFormatVersion("does_not_exist"),osmscout::IOException); | ||
} | ||
|
||
TEST_CASE("TypeConfig::GetFileFormatVersion(dir) returns current version for test database") { | ||
REQUIRE(osmscout::TypeConfig::GetDatabaseFileFormatVersion(GetTestDatabaseDirectory()) == osmscout::FILE_FORMAT_VERSION); | ||
} | ||
|
||
TEST_CASE("Database::GetFileFormatVersion(dir) returns current version for test database") { | ||
REQUIRE(osmscout::Database::GetDatabaseFileFormatVersion(GetTestDatabaseDirectory()) == osmscout::FILE_FORMAT_VERSION); | ||
} | ||
|
||
TEST_CASE("Database::GetLibraryFileFormatVersion() returns current version") { | ||
REQUIRE(osmscout::Database::GetLibraryFileFormatVersion() == osmscout::FILE_FORMAT_VERSION); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters