aboutsummaryrefslogtreecommitdiff
path: root/docs/gmock_cook_book.md
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2022-09-09 15:14:20 -0700
committerCopybara-Service <copybara-worker@google.com>2022-09-09 15:14:57 -0700
commitc29315dda476f195298ab8da180e564478649b9e (patch)
treecd9e82ce7f59fb1de0521cd8e3ddb42576b067c0 /docs/gmock_cook_book.md
parent0f6885405c980d5479d6177f7223d4bc7bacca6b (diff)
downloadgoogletest-c29315dda476f195298ab8da180e564478649b9e.zip
googletest-c29315dda476f195298ab8da180e564478649b9e.tar.gz
googletest-c29315dda476f195298ab8da180e564478649b9e.tar.bz2
Use UnorderedElementsAre in example about using matchers with maps
PiperOrigin-RevId: 473353707 Change-Id: Ief5bdbd2b8e28bac8f47be9aaeac4bb93875a793
Diffstat (limited to 'docs/gmock_cook_book.md')
-rw-r--r--docs/gmock_cook_book.md13
1 files changed, 7 insertions, 6 deletions
diff --git a/docs/gmock_cook_book.md b/docs/gmock_cook_book.md
index 8a11d86..5be298d 100644
--- a/docs/gmock_cook_book.md
+++ b/docs/gmock_cook_book.md
@@ -1424,11 +1424,12 @@ Use `Pair` when comparing maps or other associative containers.
{% raw %}
```cpp
-using testing::ElementsAre;
-using testing::Pair;
+using ::testing::UnorderedElementsAre;
+using ::testing::Pair;
...
- std::map<string, int> m = {{"a", 1}, {"b", 2}, {"c", 3}};
- EXPECT_THAT(m, ElementsAre(Pair("a", 1), Pair("b", 2), Pair("c", 3)));
+ absl::flat_hash_map<string, int> m = {{"a", 1}, {"b", 2}, {"c", 3}};
+ EXPECT_THAT(m, UnorderedElementsAre(
+ Pair("a", 1), Pair("b", 2), Pair("c", 3)));
```
{% endraw %}
@@ -1445,8 +1446,8 @@ using testing::Pair;
* If the container is passed by pointer instead of by reference, just write
`Pointee(ElementsAre*(...))`.
* The order of elements *matters* for `ElementsAre*()`. If you are using it
- with containers whose element order are undefined (e.g. `hash_map`) you
- should use `WhenSorted` around `ElementsAre`.
+ with containers whose element order are undefined (such as a
+ `std::unordered_map`) you should use `UnorderedElementsAre`.
### Sharing Matchers