aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite
diff options
context:
space:
mode:
authorFrançois Dumont <francois.cppdevs@free.fr>2011-07-24 21:20:26 +0200
committerFrançois Dumont <fdumont@gcc.gnu.org>2011-07-24 19:20:26 +0000
commit4f7b188f20a89a28a72f702b4d34b82894a1dd5f (patch)
tree3c6db059c61b19aac2c1e494763ccf3d46584377 /libstdc++-v3/testsuite
parent7d5997c66ce2a2463f8a911f6217c30759f765ce (diff)
downloadgcc-4f7b188f20a89a28a72f702b4d34b82894a1dd5f.zip
gcc-4f7b188f20a89a28a72f702b4d34b82894a1dd5f.tar.gz
gcc-4f7b188f20a89a28a72f702b4d34b82894a1dd5f.tar.bz2
hashtable_policy.h (_Prime_rehash_policy): Use __builtin_floor rather than __builtin_ceil to compute next resize value.
2011-07-24 François Dumont <francois.cppdevs@free.fr> * include/bits/hashtable_policy.h (_Prime_rehash_policy): Use __builtin_floor rather than __builtin_ceil to compute next resize value. * testsuite/23_containers/unordered_set/hash_policy/load_factor.cc: New. From-SVN: r176717
Diffstat (limited to 'libstdc++-v3/testsuite')
-rw-r--r--libstdc++-v3/testsuite/23_containers/unordered_set/hash_policy/load_factor.cc58
1 files changed, 58 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/hash_policy/load_factor.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/hash_policy/load_factor.cc
new file mode 100644
index 0000000..818274a
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/unordered_set/hash_policy/load_factor.cc
@@ -0,0 +1,58 @@
+// Copyright (C) 2011 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+//
+// { dg-options "-std=gnu++0x" }
+
+#include <unordered_set>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+ bool test __attribute__((unused)) = true;
+ {
+ std::unordered_set<int> us;
+ for (int i = 0; i != 100000; ++i)
+ {
+ us.insert(i);
+ VERIFY( us.load_factor() <= us.max_load_factor() );
+ }
+ }
+ {
+ std::unordered_set<int> us;
+ us.max_load_factor(3.f);
+ for (int i = 0; i != 100000; ++i)
+ {
+ us.insert(i);
+ VERIFY( us.load_factor() <= us.max_load_factor() );
+ }
+ }
+ {
+ std::unordered_set<int> us;
+ us.max_load_factor(.3f);
+ for (int i = 0; i != 100000; ++i)
+ {
+ us.insert(i);
+ VERIFY( us.load_factor() <= us.max_load_factor() );
+ }
+ }
+}
+
+int main()
+{
+ test01();
+ return 0;
+}