mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Make condition caching case sensitive
Correct handling of case insensitivity for paths and case sensitivity for version strings is more trouble than it's worth.
This commit is contained in:
@@ -52,14 +52,14 @@ GameCache& GameCache::operator=(const GameCache& cache) {
|
||||
|
||||
void GameCache::CacheCondition(const std::string& condition, bool result) {
|
||||
lock_guard<mutex> guard(mutex_);
|
||||
conditions_.insert(pair<string, bool>(to_lower(condition), result));
|
||||
conditions_.insert(pair<string, bool>(condition, result));
|
||||
}
|
||||
|
||||
std::pair<bool, bool> GameCache::GetCachedCondition(
|
||||
const std::string& condition) const {
|
||||
lock_guard<mutex> guard(mutex_);
|
||||
|
||||
auto it = conditions_.find(to_lower(condition));
|
||||
auto it = conditions_.find(condition);
|
||||
|
||||
if (it != conditions_.end())
|
||||
return pair<bool, bool>(it->second, true);
|
||||
|
||||
@@ -56,14 +56,21 @@ TEST_P(GameCacheTest, gettingATrueConditionShouldReturnATrueTruePair) {
|
||||
EXPECT_NO_THROW(cache_.CacheCondition(condition, true));
|
||||
|
||||
EXPECT_EQ(std::make_pair(true, true),
|
||||
cache_.GetCachedCondition(conditionLowercase));
|
||||
cache_.GetCachedCondition(condition));
|
||||
}
|
||||
|
||||
TEST_P(GameCacheTest, gettingAFalseConditionShouldReturnAFalseTruePair) {
|
||||
EXPECT_NO_THROW(cache_.CacheCondition(condition, false));
|
||||
|
||||
EXPECT_EQ(std::make_pair(false, true),
|
||||
cache_.GetCachedCondition(conditionLowercase));
|
||||
cache_.GetCachedCondition(condition));
|
||||
}
|
||||
|
||||
TEST_P(GameCacheTest, gettingACachedConditionShouldBeCaseSensitive) {
|
||||
EXPECT_NO_THROW(cache_.CacheCondition(condition, false));
|
||||
|
||||
EXPECT_EQ(std::make_pair(false, false),
|
||||
cache_.GetCachedCondition(conditionLowercase));
|
||||
}
|
||||
|
||||
TEST_P(GameCacheTest, gettingANonCachedConditionShouldReturnAFalseFalsePair) {
|
||||
|
||||
Reference in New Issue
Block a user