Fixing problem with versionChecker and adding usecase to tests

This commit is contained in:
Javier Marcos 2015-07-23 14:21:43 -07:00
parent 5f4d54741d
commit f91a96f590
2 changed files with 3 additions and 0 deletions

View File

@ -48,6 +48,8 @@ bool versionChecker(const std::string& pack, const std::string& version) {
try {
if (std::stoi(chunk) < std::stoi(required_version[index])) {
return false;
} else if (std::stoi(chunk) > std::stoi(required_version[index])) {
return true;
}
} catch (const std::invalid_argument& e) {
if (chunk.compare(required_version[index]) < 0) {

View File

@ -57,6 +57,7 @@ class QueryPacksConfigTests : public testing::Test {};
TEST_F(QueryPacksConfigTests, version_comparisons) {
EXPECT_TRUE(versionChecker("1.0.0", "1.0.0"));
EXPECT_TRUE(versionChecker("1.0.0", "1.2.0"));
EXPECT_TRUE(versionChecker("1.4.5", "1.5.0"));
EXPECT_TRUE(versionChecker("1.0", "1.2.0"));
EXPECT_TRUE(versionChecker("1.0", "1.0.2"));
EXPECT_TRUE(versionChecker("1.0.0", "1.0.2-r1"));