diff options
author | Gil <mcg@google.com> | 2018-04-20 12:11:19 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-20 12:11:19 -0700 |
commit | 0c03c28a3b7609d218a9acdff099fc0bda0f4ae6 (patch) | |
tree | 944ffbf8158b1faf75d8baa09abaec427b699222 /Firestore/core/test/firebase/firestore/immutable/testing.h | |
parent | ede57f84bb4ddcc438bba34ef4407ee86fbaf2f9 (diff) |
Implement find-related methods on C++ immutable maps (#1145)
* Standardize method ordering across sorted maps
* Add SortedMap::find
* Add SortedMap::find_index
* Add SortedMap::contains
Diffstat (limited to 'Firestore/core/test/firebase/firestore/immutable/testing.h')
-rw-r--r-- | Firestore/core/test/firebase/firestore/immutable/testing.h | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/Firestore/core/test/firebase/firestore/immutable/testing.h b/Firestore/core/test/firebase/firestore/immutable/testing.h index 0b25b66..9e839c6 100644 --- a/Firestore/core/test/firebase/firestore/immutable/testing.h +++ b/Firestore/core/test/firebase/firestore/immutable/testing.h @@ -30,6 +30,11 @@ namespace immutable { template <typename Container, typename K> testing::AssertionResult NotFound(const Container& map, const K& key) { + if (map.contains(key)) { + return testing::AssertionFailure() + << "Should not have found " << key << " using contains()"; + } + auto found = map.find(key); if (found == map.end()) { return testing::AssertionSuccess(); @@ -44,9 +49,15 @@ template <typename Container, typename K, typename V> testing::AssertionResult Found(const Container& map, const K& key, const V& expected) { + if (!map.contains(key)) { + return testing::AssertionFailure() + << "Did not find key " << key << " using contains()"; + } + auto found = map.find(key); if (found == map.end()) { - return testing::AssertionFailure() << "Did not find key " << key; + return testing::AssertionFailure() + << "Did not find key " << key << " using find()"; } if (found->second == expected) { return testing::AssertionSuccess(); |