Add CaseInsensitiveEqualTo comparison type

This commit is contained in:
Martin Hořeňovský
2021-12-26 18:54:47 +01:00
parent 156e6fdfa9
commit cbb6764fb1
12 changed files with 358 additions and 8 deletions

View File

@@ -22,5 +22,14 @@ namespace Catch {
[]( char l, char r ) { return toLower( l ) < toLower( r ); } );
}
bool
CaseInsensitiveEqualTo::operator()( StringRef lhs,
StringRef rhs ) const {
return std::equal(
lhs.begin(), lhs.end(),
rhs.begin(), rhs.end(),
[]( char l, char r ) { return toLower( l ) == toLower( r ); } );
}
} // namespace Detail
} // namespace Catch

View File

@@ -20,6 +20,12 @@ namespace Catch {
StringRef rhs ) const;
};
//! Provides case-insensitive `op==` semantics when called
struct CaseInsensitiveEqualTo {
bool operator()( StringRef lhs,
StringRef rhs ) const;
};
} // namespace Detail
} // namespace Catch