diff options
author | Marshall Clow <mclow.lists@gmail.com> | 2013-09-30 21:33:51 +0000 |
---|---|---|
committer | Marshall Clow <mclow.lists@gmail.com> | 2013-09-30 21:33:51 +0000 |
commit | 45b983c4d049e14ea9c9470bffbc72fcc38860bf (patch) | |
tree | aa29190a48de7b837c7f8f9118c44b6d22744420 /libcxx/test | |
parent | f3903a5cede4b2e628105cba7569abbe812dc27c (diff) | |
download | bcm5719-llvm-45b983c4d049e14ea9c9470bffbc72fcc38860bf.tar.gz bcm5719-llvm-45b983c4d049e14ea9c9470bffbc72fcc38860bf.zip |
Part 8 of LWG Issue 2210' unordered_set and unordered multiset; this got missed when I went on vacation
llvm-svn: 191705
Diffstat (limited to 'libcxx/test')
6 files changed, 369 insertions, 0 deletions
diff --git a/libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/allocator.pass.cpp b/libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/allocator.pass.cpp index db8ba0e79bd..af9dd01bf32 100644 --- a/libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/allocator.pass.cpp +++ b/libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/allocator.pass.cpp @@ -61,5 +61,49 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } +#if _LIBCPP_STD_VER > 11 + { + typedef NotConstructible T; + typedef test_hash<std::hash<T>> HF; + typedef test_compare<std::equal_to<T>> Comp; + typedef test_allocator<T> A; + typedef std::unordered_multiset<T, HF, Comp, A> C; + + A a(43); + C c(3, a); + assert(c.bucket_count() == 3); + assert(c.hash_function() == HF()); + assert(c.key_eq() == Comp ()); + assert(c.get_allocator() == a); + assert(!(c.get_allocator() == A())); + assert(c.size() == 0); + assert(c.empty()); + assert(std::distance(c.begin(), c.end()) == 0); + assert(c.load_factor() == 0); + assert(c.max_load_factor() == 1); + } + { + typedef NotConstructible T; + typedef test_hash<std::hash<T>> HF; + typedef test_compare<std::equal_to<T>> Comp; + typedef test_allocator<T> A; + typedef std::unordered_multiset<T, HF, Comp, A> C; + + HF hf(42); + A a(43); + C c(4, hf, a); + assert(c.bucket_count() == 4); + assert(c.hash_function() == hf); + assert(!(c.hash_function() == HF())); + assert(c.key_eq() == Comp ()); + assert(c.get_allocator() == a); + assert(!(c.get_allocator() == A())); + assert(c.size() == 0); + assert(c.empty()); + assert(std::distance(c.begin(), c.end()) == 0); + assert(c.load_factor() == 0); + assert(c.max_load_factor() == 1); + } +#endif #endif } diff --git a/libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/init.pass.cpp b/libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/init.pass.cpp index 29729b5a4b0..3578d35e534 100644 --- a/libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/init.pass.cpp +++ b/libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/init.pass.cpp @@ -88,6 +88,76 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } +#if _LIBCPP_STD_VER > 11 + { + typedef int T; + typedef test_hash<std::hash<T>> HF; + typedef test_compare<std::equal_to<T>> Comp; + typedef test_allocator<T> A; + typedef std::unordered_multiset<T, HF, Comp, A> C; + + A a(42); + C c({ + T(1), + T(2), + T(3), + T(4), + T(1), + T(2) + }, 12, a); + + assert(c.bucket_count() >= 12); + assert(c.size() == 6); + assert(c.count(1) == 2); + assert(c.count(2) == 2); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + assert(c.hash_function() == HF()); + assert(c.key_eq() == Comp()); + assert(c.get_allocator() == a); + assert(!(c.get_allocator() == A())); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } + { + typedef int T; + typedef test_hash<std::hash<T>> HF; + typedef test_compare<std::equal_to<T>> Comp; + typedef test_allocator<T> A; + typedef std::unordered_multiset<T, HF, Comp, A> C; + + A a(42); + HF hf(43); + C c({ + T(1), + T(2), + T(3), + T(4), + T(1), + T(2) + }, 12, hf, a); + + assert(c.bucket_count() >= 12); + assert(c.size() == 6); + assert(c.count(1) == 2); + assert(c.count(2) == 2); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + assert(c.hash_function() == hf); + assert(!(c.hash_function() == HF())); + assert(c.key_eq() == Comp()); + assert(c.get_allocator() == a); + assert(!(c.get_allocator() == A())); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif #endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/range.pass.cpp b/libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/range.pass.cpp index 8c0828ae417..1286eeef1ce 100644 --- a/libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/range.pass.cpp +++ b/libcxx/test/containers/unord/unord.multiset/unord.multiset.cnstr/range.pass.cpp @@ -93,5 +93,75 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } +#if _LIBCPP_STD_VER > 11 + { + typedef int T; + typedef test_hash<std::hash<T>> HF; + typedef test_compare<std::equal_to<T>> Comp; + typedef test_allocator<T> A; + typedef std::unordered_multiset<T, HF, Comp, A> C; + T arr[] = + { + T(1), + T(2), + T(3), + T(4), + T(1), + T(2) + }; + A a(42); + C c(input_iterator<T*>(arr), input_iterator<T*>(arr + sizeof(arr)/sizeof(arr[0])), 12, a); + assert(c.bucket_count() >= 12); + assert(c.size() == 6); + assert(c.count(1) == 2); + assert(c.count(2) == 2); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + assert(c.hash_function() == HF()); + assert(c.key_eq() == Comp()); + assert(c.get_allocator() == a); + assert(!(c.get_allocator() == A())); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } + { + typedef int T; + typedef test_hash<std::hash<T>> HF; + typedef test_compare<std::equal_to<T>> Comp; + typedef test_allocator<T> A; + typedef std::unordered_multiset<T, HF, Comp, A> C; + T arr[] = + { + T(1), + T(2), + T(3), + T(4), + T(1), + T(2) + }; + HF hf(43); + A a(42); + C c(input_iterator<T*>(arr), input_iterator<T*>(arr + sizeof(arr)/sizeof(arr[0])), 16, hf, a); + assert(c.bucket_count() >= 16); + assert(c.size() == 6); + assert(c.count(1) == 2); + assert(c.count(2) == 2); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + assert(c.hash_function() == hf); + assert(!(c.hash_function() == HF())); + assert(c.key_eq() == Comp()); + assert(c.get_allocator() == a); + assert(!(c.get_allocator() == A())); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif #endif } diff --git a/libcxx/test/containers/unord/unord.set/unord.set.cnstr/allocator.pass.cpp b/libcxx/test/containers/unord/unord.set/unord.set.cnstr/allocator.pass.cpp index 31878362f1e..5d7897b90f7 100644 --- a/libcxx/test/containers/unord/unord.set/unord.set.cnstr/allocator.pass.cpp +++ b/libcxx/test/containers/unord/unord.set/unord.set.cnstr/allocator.pass.cpp @@ -61,5 +61,49 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } +#if _LIBCPP_STD_VER > 11 + { + typedef NotConstructible T; + typedef test_hash<std::hash<T>> HF; + typedef test_compare<std::equal_to<T>> Comp; + typedef test_allocator<T> A; + typedef std::unordered_set<T, HF, Comp, A> C; + + A a(43); + C c(3, a); + assert(c.bucket_count() == 3); + assert(c.hash_function() == HF()); + assert(c.key_eq() == Comp ()); + assert(c.get_allocator() == a); + assert(!(c.get_allocator() == A())); + assert(c.size() == 0); + assert(c.empty()); + assert(std::distance(c.begin(), c.end()) == 0); + assert(c.load_factor() == 0); + assert(c.max_load_factor() == 1); + } + { + typedef NotConstructible T; + typedef test_hash<std::hash<T>> HF; + typedef test_compare<std::equal_to<T>> Comp; + typedef test_allocator<T> A; + typedef std::unordered_set<T, HF, Comp, A> C; + + HF hf(42); + A a(43); + C c(4, hf, a); + assert(c.bucket_count() == 4); + assert(c.hash_function() == hf); + assert(!(c.hash_function() == HF())); + assert(c.key_eq() == Comp ()); + assert(c.get_allocator() == a); + assert(!(c.get_allocator() == A())); + assert(c.size() == 0); + assert(c.empty()); + assert(std::distance(c.begin(), c.end()) == 0); + assert(c.load_factor() == 0); + assert(c.max_load_factor() == 1); + } +#endif #endif } diff --git a/libcxx/test/containers/unord/unord.set/unord.set.cnstr/init.pass.cpp b/libcxx/test/containers/unord/unord.set/unord.set.cnstr/init.pass.cpp index 8dc37e30465..fcee4007ee0 100644 --- a/libcxx/test/containers/unord/unord.set/unord.set.cnstr/init.pass.cpp +++ b/libcxx/test/containers/unord/unord.set/unord.set.cnstr/init.pass.cpp @@ -88,6 +88,76 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } +#if _LIBCPP_STD_VER > 11 + { + typedef int T; + typedef test_hash<std::hash<T>> HF; + typedef test_compare<std::equal_to<T>> Comp; + typedef test_allocator<T> A; + typedef std::unordered_set<T, HF, Comp, A> C; + + A a(42); + C c({ + T(1), + T(2), + T(3), + T(4), + T(1), + T(2) + }, 12, a); + + assert(c.bucket_count() >= 12); + assert(c.size() == 4); + assert(c.count(1) == 1); + assert(c.count(2) == 1); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + assert(c.hash_function() == HF()); + assert(c.key_eq() == Comp()); + assert(c.get_allocator() == a); + assert(!(c.get_allocator() == A())); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } + { + typedef int T; + typedef test_hash<std::hash<T>> HF; + typedef test_compare<std::equal_to<T>> Comp; + typedef test_allocator<T> A; + typedef std::unordered_set<T, HF, Comp, A> C; + + A a(42); + HF hf(43); + C c({ + T(1), + T(2), + T(3), + T(4), + T(1), + T(2) + }, 12, hf, a); + + assert(c.bucket_count() >= 12); + assert(c.size() == 4); + assert(c.count(1) == 1); + assert(c.count(2) == 1); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + assert(c.hash_function() == hf); + assert(!(c.hash_function() == HF())); + assert(c.key_eq() == Comp()); + assert(c.get_allocator() == a); + assert(!(c.get_allocator() == A())); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } +#endif #endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS } diff --git a/libcxx/test/containers/unord/unord.set/unord.set.cnstr/range.pass.cpp b/libcxx/test/containers/unord/unord.set/unord.set.cnstr/range.pass.cpp index 322fa3ff5a3..d0166fab893 100644 --- a/libcxx/test/containers/unord/unord.set/unord.set.cnstr/range.pass.cpp +++ b/libcxx/test/containers/unord/unord.set/unord.set.cnstr/range.pass.cpp @@ -93,5 +93,76 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } +#if _LIBCPP_STD_VER > 11 + { + typedef int T; + typedef test_hash<std::hash<T>> HF; + typedef test_compare<std::equal_to<T>> Comp; + typedef test_allocator<T> A; + typedef std::unordered_set<T, HF, Comp, A> C; + T arr[] = + { + T(1), + T(2), + T(3), + T(4), + T(1), + T(2) + }; + A a(42); + C c(input_iterator<T*>(arr), input_iterator<T*>(arr + sizeof(arr)/sizeof(arr[0])), 12, a); + assert(c.bucket_count() >= 12); + assert(c.size() == 4); + assert(c.count(1) == 1); + assert(c.count(2) == 1); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + assert(c.hash_function() == HF()); + assert(c.key_eq() == Comp()); + assert(c.get_allocator() == a); + assert(!(c.get_allocator() == A())); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } + { + typedef int T; + typedef test_hash<std::hash<T>> HF; + typedef test_compare<std::equal_to<T>> Comp; + typedef test_allocator<T> A; + typedef std::unordered_set<T, HF, Comp, A> C; + T arr[] = + { + T(1), + T(2), + T(3), + T(4), + T(1), + T(2) + }; + HF hf(43); + A a(42); + C c(input_iterator<T*>(arr), input_iterator<T*>(arr + sizeof(arr)/sizeof(arr[0])), 16, hf, a); + assert(c.bucket_count() >= 16); + assert(c.size() == 4); + assert(c.count(1) == 1); + assert(c.count(2) == 1); + assert(c.count(3) == 1); + assert(c.count(4) == 1); + assert(c.hash_function() == hf); + assert(!(c.hash_function() == HF())); + assert(c.key_eq() == Comp()); + assert(c.get_allocator() == a); + assert(!(c.get_allocator() == A())); + assert(!c.empty()); + assert(std::distance(c.begin(), c.end()) == c.size()); + assert(std::distance(c.cbegin(), c.cend()) == c.size()); + assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); + assert(c.max_load_factor() == 1); + } + +#endif #endif } |