Use UnorderedElementsAre in example about using matchers with maps
PiperOrigin-RevId: 473353707 Change-Id: Ief5bdbd2b8e28bac8f47be9aaeac4bb93875a793
This commit is contained in:
		
				
					committed by
					
						
						Copybara-Service
					
				
			
			
				
	
			
			
			
						parent
						
							0f6885405c
						
					
				
				
					commit
					c29315dda4
				
			@@ -1424,11 +1424,12 @@ Use `Pair` when comparing maps or other associative containers.
 | 
				
			|||||||
{% raw %}
 | 
					{% raw %}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```cpp
 | 
					```cpp
 | 
				
			||||||
using testing::ElementsAre;
 | 
					using ::testing::UnorderedElementsAre;
 | 
				
			||||||
using testing::Pair;
 | 
					using ::testing::Pair;
 | 
				
			||||||
...
 | 
					...
 | 
				
			||||||
  std::map<string, int> m = {{"a", 1}, {"b", 2}, {"c", 3}};
 | 
					  absl::flat_hash_map<string, int> m = {{"a", 1}, {"b", 2}, {"c", 3}};
 | 
				
			||||||
  EXPECT_THAT(m, ElementsAre(Pair("a", 1), Pair("b", 2), Pair("c", 3)));
 | 
					  EXPECT_THAT(m, UnorderedElementsAre(
 | 
				
			||||||
 | 
					      Pair("a", 1), Pair("b", 2), Pair("c", 3)));
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
{% endraw %}
 | 
					{% endraw %}
 | 
				
			||||||
@@ -1445,8 +1446,8 @@ using testing::Pair;
 | 
				
			|||||||
*   If the container is passed by pointer instead of by reference, just write
 | 
					*   If the container is passed by pointer instead of by reference, just write
 | 
				
			||||||
    `Pointee(ElementsAre*(...))`.
 | 
					    `Pointee(ElementsAre*(...))`.
 | 
				
			||||||
*   The order of elements *matters* for `ElementsAre*()`. If you are using it
 | 
					*   The order of elements *matters* for `ElementsAre*()`. If you are using it
 | 
				
			||||||
    with containers whose element order are undefined (e.g. `hash_map`) you
 | 
					    with containers whose element order are undefined (such as a
 | 
				
			||||||
    should use `WhenSorted` around `ElementsAre`.
 | 
					    `std::unordered_map`) you should use `UnorderedElementsAre`.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
### Sharing Matchers
 | 
					### Sharing Matchers
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user