Fix hash function comparator

This commit is contained in:
Tatsuhiro Tsujikawa 2014-09-11 23:54:17 +09:00
parent 528cf5395b
commit c0b8b471ab
2 changed files with 5 additions and 2 deletions

View File

@ -135,9 +135,12 @@ bool MessageDigest::isStronger(const std::string& lhs, const std::string& rhs)
FindHashTypeEntry(lhs));
auto rEntry = std::find_if(std::begin(hashTypes), std::end(hashTypes),
FindHashTypeEntry(rhs));
if(lEntry == std::end(hashTypes) || rEntry == std::end(hashTypes)) {
if(lEntry == std::end(hashTypes)) {
return false;
}
if(rEntry == std::end(hashTypes)) {
return true;
}
return lEntry->strength > rEntry->strength;
}

View File

@ -76,7 +76,7 @@ void MessageDigestTest::testIsStronger()
CPPUNIT_ASSERT(MessageDigest::isStronger("sha-1", "md5"));
CPPUNIT_ASSERT(!MessageDigest::isStronger("md5", "sha-1"));
CPPUNIT_ASSERT(!MessageDigest::isStronger("unknown", "sha-1"));
CPPUNIT_ASSERT(!MessageDigest::isStronger("sha-1", "unknown"));
CPPUNIT_ASSERT(MessageDigest::isStronger("sha-1", "unknown"));
}
void MessageDigestTest::testIsValidHash()