diff options
Diffstat (limited to 'test/std/containers/associative/map/map.access')
7 files changed, 73 insertions, 9 deletions
diff --git a/test/std/containers/associative/map/map.access/at.pass.cpp b/test/std/containers/associative/map/map.access/at.pass.cpp index 0da28507fce39..c5f77bf5f0fb6 100644 --- a/test/std/containers/associative/map/map.access/at.pass.cpp +++ b/test/std/containers/associative/map/map.access/at.pass.cpp @@ -86,7 +86,7 @@ int main() assert(m.at(8) == 8.5); assert(m.size() == 7); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::pair<const int, double> V; V ar[] = diff --git a/test/std/containers/associative/map/map.access/empty.pass.cpp b/test/std/containers/associative/map/map.access/empty.pass.cpp index b11e94c8042ca..17b9cfd4ec110 100644 --- a/test/std/containers/associative/map/map.access/empty.pass.cpp +++ b/test/std/containers/associative/map/map.access/empty.pass.cpp @@ -29,7 +29,7 @@ int main() m.clear(); assert(m.empty()); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M; M m; diff --git a/test/std/containers/associative/map/map.access/index_key.pass.cpp b/test/std/containers/associative/map/map.access/index_key.pass.cpp index ab1144c60afda..3b1c21fd5da44 100644 --- a/test/std/containers/associative/map/map.access/index_key.pass.cpp +++ b/test/std/containers/associative/map/map.access/index_key.pass.cpp @@ -16,8 +16,13 @@ #include <map> #include <cassert> +#include "test_macros.h" +#include "count_new.hpp" #include "min_allocator.h" #include "private_constructor.hpp" +#if TEST_STD_VER >= 11 +#include "container_test_types.h" +#endif int main() { @@ -46,7 +51,7 @@ int main() assert(m[6] == 6.5); assert(m.size() == 8); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::pair<const int, double> V; V ar[] = @@ -73,8 +78,42 @@ int main() assert(m[6] == 6.5); assert(m.size() == 8); } + { + // Use "container_test_types.h" to check what arguments get passed + // to the allocator for operator[] + using Container = TCT::map<>; + using Key = Container::key_type; + using MappedType = Container::mapped_type; + using ValueTp = Container::value_type; + ConstructController* cc = getConstructController(); + cc->reset(); + { + Container c; + const Key k(1); + cc->expect<std::piecewise_construct_t const&, std::tuple<Key const&>&&, std::tuple<>&&>(); + MappedType& mref = c[k]; + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + MappedType& mref2 = c[k]; + assert(&mref == &mref2); + } + } + { + Container c; + Key k(1); + cc->expect<std::piecewise_construct_t const&, std::tuple<Key const&>&&, std::tuple<>&&>(); + MappedType& mref = c[k]; + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + MappedType& mref2 = c[k]; + assert(&mref == &mref2); + } + } + } #endif -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 { typedef std::pair<const int, double> V; V ar[] = diff --git a/test/std/containers/associative/map/map.access/index_rv_key.pass.cpp b/test/std/containers/associative/map/map.access/index_rv_key.pass.cpp index 6511dcc85f531..e5580bca3955d 100644 --- a/test/std/containers/associative/map/map.access/index_rv_key.pass.cpp +++ b/test/std/containers/associative/map/map.access/index_rv_key.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <map> // class map @@ -17,12 +19,13 @@ #include <cassert> #include "test_macros.h" +#include "count_new.hpp" #include "MoveOnly.h" #include "min_allocator.h" +#include "container_test_types.h" int main() { -#if TEST_STD_VER >= 11 { std::map<MoveOnly, double> m; assert(m.size() == 0); @@ -52,5 +55,27 @@ int main() assert(m[6] == 6.5); assert(m.size() == 2); } -#endif + { + // Use "container_test_types.h" to check what arguments get passed + // to the allocator for operator[] + using Container = TCT::map<>; + using Key = Container::key_type; + using MappedType = Container::mapped_type; + using ValueTp = Container::value_type; + ConstructController* cc = getConstructController(); + cc->reset(); + { + Container c; + Key k(1); + cc->expect<std::piecewise_construct_t const&, std::tuple<Key &&>&&, std::tuple<>&&>(); + MappedType& mref = c[std::move(k)]; + assert(!cc->unchecked()); + { + Key k2(1); + DisableAllocationGuard g; + MappedType& mref2 = c[std::move(k2)]; + assert(&mref == &mref2); + } + } + } } diff --git a/test/std/containers/associative/map/map.access/iterator.pass.cpp b/test/std/containers/associative/map/map.access/iterator.pass.cpp index 552e87d8fc8d3..4f66eb6a8e310 100644 --- a/test/std/containers/associative/map/map.access/iterator.pass.cpp +++ b/test/std/containers/associative/map/map.access/iterator.pass.cpp @@ -119,7 +119,7 @@ int main() assert(i->second == 1); } } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::pair<const int, double> V; V ar[] = diff --git a/test/std/containers/associative/map/map.access/max_size.pass.cpp b/test/std/containers/associative/map/map.access/max_size.pass.cpp index 551120d331e17..c67d8b1f674db 100644 --- a/test/std/containers/associative/map/map.access/max_size.pass.cpp +++ b/test/std/containers/associative/map/map.access/max_size.pass.cpp @@ -25,7 +25,7 @@ int main() M m; assert(m.max_size() != 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M; M m; diff --git a/test/std/containers/associative/map/map.access/size.pass.cpp b/test/std/containers/associative/map/map.access/size.pass.cpp index 07c12322a460b..b9d56167a4b04 100644 --- a/test/std/containers/associative/map/map.access/size.pass.cpp +++ b/test/std/containers/associative/map/map.access/size.pass.cpp @@ -37,7 +37,7 @@ int main() m.erase(m.begin()); assert(m.size() == 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M; M m; |