diff options
Diffstat (limited to 'libcxx/test/std/containers/associative')
4 files changed, 29 insertions, 9 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); + } } diff --git a/libcxx/test/std/containers/associative/map/map.access/index_rv_key.pass.cpp b/libcxx/test/std/containers/associative/map/map.access/index_rv_key.pass.cpp index d14603e1a28..7e0fd41d56a 100644 --- a/libcxx/test/std/containers/associative/map/map.access/index_rv_key.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.access/index_rv_key.pass.cpp @@ -16,14 +16,14 @@ #include <map> #include <cassert> +#include "test_macros.h" #include "MoveOnly.h" #include "min_allocator.h" int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#if TEST_STD_VER >= 11 { - typedef std::pair<MoveOnly, double> V; std::map<MoveOnly, double> m; assert(m.size() == 0); assert(m[1] == 0.0); @@ -37,8 +37,6 @@ int main() assert(m[6] == 6.5); assert(m.size() == 2); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -#if __cplusplus >= 201103L { typedef std::pair<MoveOnly, double> V; std::map<MoveOnly, double, std::less<MoveOnly>, min_allocator<V>> m; diff --git a/libcxx/test/std/containers/associative/multimap/scary.pass.cpp b/libcxx/test/std/containers/associative/multimap/scary.pass.cpp index b99d9bc2df9..e6dc5aaca95 100644 --- a/libcxx/test/std/containers/associative/multimap/scary.pass.cpp +++ b/libcxx/test/std/containers/associative/multimap/scary.pass.cpp @@ -21,4 +21,5 @@ int main() typedef std::multimap<int, int> M2; M2::iterator i; M1::iterator j = i; + ((void)j); } diff --git a/libcxx/test/std/containers/associative/multiset/scary.pass.cpp b/libcxx/test/std/containers/associative/multiset/scary.pass.cpp index f5ee32714e8..bc4328b5332 100644 --- a/libcxx/test/std/containers/associative/multiset/scary.pass.cpp +++ b/libcxx/test/std/containers/associative/multiset/scary.pass.cpp @@ -21,4 +21,5 @@ int main() typedef std::multiset<int> M2; M2::iterator i; M1::iterator j = i; + ((void)j); } |