mirror of
https://github.com/apple/foundationdb.git
synced 2025-05-15 02:18:39 +08:00
Add two unit tests for the new hashing functionality
This commit is contained in:
parent
0dabd85e3b
commit
39a7dc7a2d
@ -613,3 +613,40 @@ TEST_CASE("/flow/Arena/SmallVectorRef10") {
|
||||
testVectorLike<SmallVectorRef10Proxy>();
|
||||
return Void();
|
||||
}
|
||||
|
||||
TEST_CASE("/flow/Arena/OptionalHash") {
|
||||
std::hash<Optional<int>> hashFunc{};
|
||||
Optional<int> a;
|
||||
Optional<int> b;
|
||||
Optional<int> c = 1;
|
||||
Optional<int> d = 1;
|
||||
Optional<int> e = 2;
|
||||
|
||||
ASSERT(hashFunc(a) == hashFunc(b));
|
||||
ASSERT(hashFunc(a) != hashFunc(c));
|
||||
ASSERT(hashFunc(c) == hashFunc(d));
|
||||
ASSERT(hashFunc(c) != hashFunc(e));
|
||||
ASSERT(hashFunc(a) == hashFunc(a));
|
||||
ASSERT(hashFunc(c) == hashFunc(c));
|
||||
|
||||
return Void();
|
||||
}
|
||||
|
||||
TEST_CASE("/flow/Arena/DefaultBoostHash") {
|
||||
boost::hash<std::pair<Optional<int>, StringRef>> hashFunc;
|
||||
|
||||
auto a = std::make_pair(Optional<int>(), "foo"_sr);
|
||||
auto b = std::make_pair(Optional<int>(), "foo"_sr);
|
||||
auto c = std::make_pair(Optional<int>(), "bar"_sr);
|
||||
auto d = std::make_pair(Optional<int>(1), "foo"_sr);
|
||||
auto e = std::make_pair(Optional<int>(1), "foo"_sr);
|
||||
|
||||
ASSERT(hashFunc(a) == hashFunc(b));
|
||||
ASSERT(hashFunc(a) != hashFunc(c));
|
||||
ASSERT(hashFunc(a) != hashFunc(d));
|
||||
ASSERT(hashFunc(d) == hashFunc(e));
|
||||
ASSERT(hashFunc(a) == hashFunc(a));
|
||||
ASSERT(hashFunc(d) == hashFunc(d));
|
||||
|
||||
return Void();
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user