mirror of
https://github.com/valitydev/osquery-1.git
synced 2024-11-07 09:58:54 +00:00
Fixing problem with versionChecker and adding usecase to tests
This commit is contained in:
parent
5f4d54741d
commit
f91a96f590
@ -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) {
|
||||
|
@ -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"));
|
||||
|
Loading…
Reference in New Issue
Block a user