summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/containers/associative/map/compare.pass.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/test/std/containers/associative/map/compare.pass.cpp')
-rw-r--r--libcxx/test/std/containers/associative/map/compare.pass.cpp30
1 files changed, 25 insertions, 5 deletions
diff --git a/libcxx/test/std/containers/associative/map/compare.pass.cpp b/libcxx/test/std/containers/associative/map/compare.pass.cpp
index aa4d5999ff4..26ac7af7d90 100644
--- a/libcxx/test/std/containers/associative/map/compare.pass.cpp
+++ b/libcxx/test/std/containers/associative/map/compare.pass.cpp
@@ -17,16 +17,36 @@
// http://llvm.org/bugs/show_bug.cgi?id=16549
#include <map>
+#include <utility>
+#include <cassert>
struct Key {
template <typename T> Key(const T&) {}
bool operator< (const Key&) const { return false; }
};
-int
-main()
+int main()
{
- std::map<Key, int>::iterator it = std::map<Key, int>().find(Key(0));
- std::pair<std::map<Key, int>::iterator, bool> result =
- std::map<Key, int>().insert(std::make_pair(Key(0), 0));
+ typedef std::map<Key, int> MapT;
+ typedef MapT::iterator Iter;
+ typedef std::pair<Iter, bool> IterBool;
+ {
+ MapT m_empty;
+ MapT m_contains;
+ m_contains[Key(0)] = 42;
+
+ Iter it = m_empty.find(Key(0));
+ assert(it == m_empty.end());
+ it = m_contains.find(Key(0));
+ assert(it != m_contains.end());
+ }
+ {
+ MapT map;
+ IterBool result = map.insert(std::make_pair(Key(0), 42));
+ assert(result.second);
+ assert(result.first->second = 42);
+ IterBool result2 = map.insert(std::make_pair(Key(0), 43));
+ assert(!result2.second);
+ assert(map[Key(0)] == 42);
+ }
}
OpenPOWER on IntegriCloud