unord test fixes by Edward Meewis

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@145707 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Howard Hinnant
2011-12-02 21:23:14 +00:00
parent e814a90f74
commit f836d531b4
73 changed files with 166 additions and 93 deletions

View File

@@ -18,6 +18,7 @@
#include <unordered_map> #include <unordered_map>
#include <string> #include <string>
#include <cassert> #include <cassert>
#include <cfloat>
int main() int main()
{ {
@@ -36,7 +37,7 @@ int main()
P(80, "eighty"), P(80, "eighty"),
}; };
const C c(std::begin(a), std::end(a)); const C c(std::begin(a), std::end(a));
assert(c.load_factor() == (float)c.size() / c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
} }
{ {
typedef std::unordered_map<int, std::string> C; typedef std::unordered_map<int, std::string> C;

View File

@@ -18,6 +18,7 @@
#include <unordered_map> #include <unordered_map>
#include <string> #include <string>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../test_compare.h" #include "../../../test_compare.h"
#include "../../../test_hash.h" #include "../../../test_hash.h"
@@ -67,7 +68,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
{ {
@@ -112,7 +113,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
} }

View File

@@ -18,6 +18,7 @@
#include <unordered_map> #include <unordered_map>
#include <string> #include <string>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../test_compare.h" #include "../../../test_compare.h"
#include "../../../test_hash.h" #include "../../../test_hash.h"
@@ -54,7 +55,7 @@ int main()
assert(c.at(4) == "four"); assert(c.at(4) == "four");
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS

View File

@@ -18,6 +18,7 @@
#include <unordered_map> #include <unordered_map>
#include <string> #include <string>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../test_compare.h" #include "../../../test_compare.h"
#include "../../../test_hash.h" #include "../../../test_hash.h"
@@ -68,7 +69,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
{ {
@@ -113,7 +114,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
assert(c0.size() == 0); assert(c0.size() == 0);
} }
@@ -159,7 +160,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
assert(c0.size() == 0); assert(c0.size() == 0);
} }

View File

@@ -18,6 +18,7 @@
#include <unordered_map> #include <unordered_map>
#include <string> #include <string>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../test_compare.h" #include "../../../test_compare.h"
#include "../../../test_hash.h" #include "../../../test_hash.h"
@@ -61,7 +62,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE #ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
@@ -101,7 +102,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE #endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE

View File

@@ -18,6 +18,7 @@
#include <unordered_map> #include <unordered_map>
#include <string> #include <string>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../test_compare.h" #include "../../../test_compare.h"
#include "../../../test_hash.h" #include "../../../test_hash.h"
@@ -61,7 +62,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
} }

View File

@@ -18,6 +18,7 @@
#include <unordered_map> #include <unordered_map>
#include <string> #include <string>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../test_compare.h" #include "../../../test_compare.h"
#include "../../../test_hash.h" #include "../../../test_hash.h"
@@ -54,7 +55,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS

View File

@@ -18,6 +18,7 @@
#include <unordered_map> #include <unordered_map>
#include <string> #include <string>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../test_compare.h" #include "../../../test_compare.h"
#include "../../../test_hash.h" #include "../../../test_hash.h"
@@ -56,7 +57,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS

View File

@@ -18,6 +18,7 @@
#include <unordered_map> #include <unordered_map>
#include <string> #include <string>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../test_compare.h" #include "../../../test_compare.h"
#include "../../../test_hash.h" #include "../../../test_hash.h"
@@ -57,7 +58,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS

View File

@@ -19,6 +19,7 @@
#include <unordered_map> #include <unordered_map>
#include <string> #include <string>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../test_compare.h" #include "../../../test_compare.h"
#include "../../../test_hash.h" #include "../../../test_hash.h"
@@ -59,7 +60,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS

View File

@@ -19,6 +19,7 @@
#include <unordered_map> #include <unordered_map>
#include <string> #include <string>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../test_compare.h" #include "../../../test_compare.h"
#include "../../../test_hash.h" #include "../../../test_hash.h"
@@ -60,7 +61,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS

View File

@@ -18,6 +18,7 @@
#include <unordered_map> #include <unordered_map>
#include <string> #include <string>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../test_compare.h" #include "../../../test_compare.h"
#include "../../../test_hash.h" #include "../../../test_hash.h"
@@ -98,7 +99,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
assert(c0.empty()); assert(c0.empty());

View File

@@ -18,6 +18,7 @@
#include <unordered_map> #include <unordered_map>
#include <string> #include <string>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../test_compare.h" #include "../../../test_compare.h"
#include "../../../test_hash.h" #include "../../../test_hash.h"
@@ -62,7 +63,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
assert(c0.empty()); assert(c0.empty());
@@ -103,7 +104,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
assert(c0.empty()); assert(c0.empty());

View File

@@ -19,6 +19,7 @@
#include <unordered_map> #include <unordered_map>
#include <string> #include <string>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../iterators.h" #include "../../../iterators.h"
#include "../../../NotConstructible.h" #include "../../../NotConstructible.h"
@@ -58,7 +59,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
} }

View File

@@ -19,6 +19,7 @@
#include <unordered_map> #include <unordered_map>
#include <string> #include <string>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../iterators.h" #include "../../../iterators.h"
#include "../../../NotConstructible.h" #include "../../../NotConstructible.h"
@@ -60,7 +61,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
} }

View File

@@ -20,6 +20,7 @@
#include <unordered_map> #include <unordered_map>
#include <string> #include <string>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../iterators.h" #include "../../../iterators.h"
#include "../../../NotConstructible.h" #include "../../../NotConstructible.h"
@@ -62,7 +63,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
} }

View File

@@ -20,6 +20,7 @@
#include <unordered_map> #include <unordered_map>
#include <string> #include <string>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../iterators.h" #include "../../../iterators.h"
#include "../../../NotConstructible.h" #include "../../../NotConstructible.h"
@@ -63,7 +64,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
} }

View File

@@ -21,6 +21,7 @@
#include <unordered_map> #include <unordered_map>
#include <string> #include <string>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../iterators.h" #include "../../../iterators.h"
#include "../../../NotConstructible.h" #include "../../../NotConstructible.h"
@@ -65,7 +66,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
} }

View File

@@ -18,6 +18,7 @@
#include <unordered_map> #include <unordered_map>
#include <string> #include <string>
#include <cassert> #include <cassert>
#include <cfloat>
int main() int main()
{ {
@@ -36,7 +37,7 @@ int main()
P(80, "eighty"), P(80, "eighty"),
}; };
const C c(std::begin(a), std::end(a)); const C c(std::begin(a), std::end(a));
assert(c.load_factor() == (float)c.size() / c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
} }
{ {
typedef std::unordered_multimap<int, std::string> C; typedef std::unordered_multimap<int, std::string> C;

View File

@@ -18,6 +18,7 @@
#include <unordered_map> #include <unordered_map>
#include <string> #include <string>
#include <cassert> #include <cassert>
#include <cfloat>
void test(const std::unordered_multimap<int, std::string>& c) void test(const std::unordered_multimap<int, std::string>& c)
{ {
@@ -53,7 +54,7 @@ void test(const std::unordered_multimap<int, std::string>& c)
assert(i->second == "four"); assert(i->second == "four");
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
} }
int main() int main()

View File

@@ -18,6 +18,7 @@
#include <unordered_map> #include <unordered_map>
#include <string> #include <string>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../test_compare.h" #include "../../../test_compare.h"
#include "../../../test_hash.h" #include "../../../test_hash.h"
@@ -81,7 +82,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
{ {
@@ -140,7 +141,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
} }

View File

@@ -18,6 +18,7 @@
#include <unordered_map> #include <unordered_map>
#include <string> #include <string>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../test_compare.h" #include "../../../test_compare.h"
#include "../../../test_hash.h" #include "../../../test_hash.h"
@@ -79,7 +80,7 @@ int main()
assert(i->second == "four"); assert(i->second == "four");
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS

View File

@@ -18,6 +18,7 @@
#include <unordered_map> #include <unordered_map>
#include <string> #include <string>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../test_compare.h" #include "../../../test_compare.h"
#include "../../../test_hash.h" #include "../../../test_hash.h"
@@ -88,7 +89,7 @@ int main()
assert(i->second == "four"); assert(i->second == "four");
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
{ {
@@ -153,7 +154,7 @@ int main()
assert(i->second == "four"); assert(i->second == "four");
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
{ {
@@ -218,7 +219,7 @@ int main()
assert(i->second == "four"); assert(i->second == "four");
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES

View File

@@ -18,6 +18,7 @@
#include <unordered_map> #include <unordered_map>
#include <string> #include <string>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../test_compare.h" #include "../../../test_compare.h"
#include "../../../test_hash.h" #include "../../../test_hash.h"
@@ -75,7 +76,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE #ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
@@ -129,7 +130,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE #endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE

View File

@@ -18,6 +18,7 @@
#include <unordered_map> #include <unordered_map>
#include <string> #include <string>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../test_compare.h" #include "../../../test_compare.h"
#include "../../../test_hash.h" #include "../../../test_hash.h"
@@ -75,7 +76,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
} }

View File

@@ -18,6 +18,7 @@
#include <unordered_map> #include <unordered_map>
#include <string> #include <string>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../test_compare.h" #include "../../../test_compare.h"
#include "../../../test_hash.h" #include "../../../test_hash.h"
@@ -73,7 +74,7 @@ int main()
assert(i->second == "four"); assert(i->second == "four");
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
assert(c.hash_function() == test_hash<std::hash<int> >()); assert(c.hash_function() == test_hash<std::hash<int> >());
assert(c.key_eq() == test_compare<std::equal_to<int> >()); assert(c.key_eq() == test_compare<std::equal_to<int> >());

View File

@@ -18,6 +18,7 @@
#include <unordered_map> #include <unordered_map>
#include <string> #include <string>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../test_compare.h" #include "../../../test_compare.h"
#include "../../../test_hash.h" #include "../../../test_hash.h"
@@ -75,7 +76,7 @@ int main()
assert(i->second == "four"); assert(i->second == "four");
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
assert(c.hash_function() == test_hash<std::hash<int> >()); assert(c.hash_function() == test_hash<std::hash<int> >());
assert(c.key_eq() == test_compare<std::equal_to<int> >()); assert(c.key_eq() == test_compare<std::equal_to<int> >());

View File

@@ -18,6 +18,7 @@
#include <unordered_map> #include <unordered_map>
#include <string> #include <string>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../test_compare.h" #include "../../../test_compare.h"
#include "../../../test_hash.h" #include "../../../test_hash.h"
@@ -76,7 +77,7 @@ int main()
assert(i->second == "four"); assert(i->second == "four");
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
assert(c.hash_function() == test_hash<std::hash<int> >(8)); assert(c.hash_function() == test_hash<std::hash<int> >(8));
assert(c.key_eq() == test_compare<std::equal_to<int> >()); assert(c.key_eq() == test_compare<std::equal_to<int> >());

View File

@@ -19,6 +19,7 @@
#include <unordered_map> #include <unordered_map>
#include <string> #include <string>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../test_compare.h" #include "../../../test_compare.h"
#include "../../../test_hash.h" #include "../../../test_hash.h"
@@ -78,7 +79,7 @@ int main()
assert(i->second == "four"); assert(i->second == "four");
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
assert(c.hash_function() == test_hash<std::hash<int> >(8)); assert(c.hash_function() == test_hash<std::hash<int> >(8));
assert(c.key_eq() == test_compare<std::equal_to<int> >(9)); assert(c.key_eq() == test_compare<std::equal_to<int> >(9));

View File

@@ -19,6 +19,7 @@
#include <unordered_map> #include <unordered_map>
#include <string> #include <string>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../test_compare.h" #include "../../../test_compare.h"
#include "../../../test_hash.h" #include "../../../test_hash.h"
@@ -79,7 +80,7 @@ int main()
assert(i->second == "four"); assert(i->second == "four");
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
assert(c.hash_function() == test_hash<std::hash<int> >(8)); assert(c.hash_function() == test_hash<std::hash<int> >(8));
assert(c.key_eq() == test_compare<std::equal_to<int> >(9)); assert(c.key_eq() == test_compare<std::equal_to<int> >(9));

View File

@@ -18,6 +18,7 @@
#include <unordered_map> #include <unordered_map>
#include <string> #include <string>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../test_compare.h" #include "../../../test_compare.h"
#include "../../../test_hash.h" #include "../../../test_hash.h"
@@ -117,7 +118,7 @@ int main()
assert(i->second == "four"); assert(i->second == "four");
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
assert(c.hash_function() == test_hash<std::hash<int> >(8)); assert(c.hash_function() == test_hash<std::hash<int> >(8));
assert(c.key_eq() == test_compare<std::equal_to<int> >(9)); assert(c.key_eq() == test_compare<std::equal_to<int> >(9));

View File

@@ -20,6 +20,7 @@
#include <unordered_map> #include <unordered_map>
#include <string> #include <string>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../test_compare.h" #include "../../../test_compare.h"
#include "../../../test_hash.h" #include "../../../test_hash.h"
@@ -84,7 +85,7 @@ int main()
assert(i->second == "four"); assert(i->second == "four");
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
assert(c.hash_function() == test_hash<std::hash<int> >(8)); assert(c.hash_function() == test_hash<std::hash<int> >(8));
assert(c.key_eq() == test_compare<std::equal_to<int> >(9)); assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
@@ -148,7 +149,7 @@ int main()
assert(i->second == "four"); assert(i->second == "four");
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
assert(c.hash_function() == test_hash<std::hash<int> >(8)); assert(c.hash_function() == test_hash<std::hash<int> >(8));
assert(c.key_eq() == test_compare<std::equal_to<int> >(9)); assert(c.key_eq() == test_compare<std::equal_to<int> >(9));

View File

@@ -19,6 +19,7 @@
#include <unordered_map> #include <unordered_map>
#include <string> #include <string>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../iterators.h" #include "../../../iterators.h"
#include "../../../NotConstructible.h" #include "../../../NotConstructible.h"
@@ -77,7 +78,7 @@ int main()
assert(i->second == "four"); assert(i->second == "four");
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
assert(c.hash_function() == test_hash<std::hash<int> >()); assert(c.hash_function() == test_hash<std::hash<int> >());
assert(c.key_eq() == test_compare<std::equal_to<int> >()); assert(c.key_eq() == test_compare<std::equal_to<int> >());

View File

@@ -19,6 +19,7 @@
#include <unordered_map> #include <unordered_map>
#include <string> #include <string>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../iterators.h" #include "../../../iterators.h"
#include "../../../NotConstructible.h" #include "../../../NotConstructible.h"
@@ -79,7 +80,7 @@ int main()
assert(i->second == "four"); assert(i->second == "four");
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
assert(c.hash_function() == test_hash<std::hash<int> >()); assert(c.hash_function() == test_hash<std::hash<int> >());
assert(c.key_eq() == test_compare<std::equal_to<int> >()); assert(c.key_eq() == test_compare<std::equal_to<int> >());

View File

@@ -20,6 +20,7 @@
#include <unordered_map> #include <unordered_map>
#include <string> #include <string>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../iterators.h" #include "../../../iterators.h"
#include "../../../NotConstructible.h" #include "../../../NotConstructible.h"
@@ -81,7 +82,7 @@ int main()
assert(i->second == "four"); assert(i->second == "four");
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
assert(c.hash_function() == test_hash<std::hash<int> >(8)); assert(c.hash_function() == test_hash<std::hash<int> >(8));
assert(c.key_eq() == test_compare<std::equal_to<int> >()); assert(c.key_eq() == test_compare<std::equal_to<int> >());

View File

@@ -20,6 +20,7 @@
#include <unordered_map> #include <unordered_map>
#include <string> #include <string>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../iterators.h" #include "../../../iterators.h"
#include "../../../NotConstructible.h" #include "../../../NotConstructible.h"
@@ -82,7 +83,7 @@ int main()
assert(i->second == "four"); assert(i->second == "four");
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
assert(c.hash_function() == test_hash<std::hash<int> >(8)); assert(c.hash_function() == test_hash<std::hash<int> >(8));
assert(c.key_eq() == test_compare<std::equal_to<int> >(9)); assert(c.key_eq() == test_compare<std::equal_to<int> >(9));

View File

@@ -21,6 +21,7 @@
#include <unordered_map> #include <unordered_map>
#include <string> #include <string>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../iterators.h" #include "../../../iterators.h"
#include "../../../NotConstructible.h" #include "../../../NotConstructible.h"
@@ -84,7 +85,7 @@ int main()
assert(i->second == "four"); assert(i->second == "four");
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
assert(c.hash_function() == test_hash<std::hash<int> >(8)); assert(c.hash_function() == test_hash<std::hash<int> >(8));
assert(c.key_eq() == test_compare<std::equal_to<int> >(9)); assert(c.key_eq() == test_compare<std::equal_to<int> >(9));

View File

@@ -17,6 +17,7 @@
#include <unordered_set> #include <unordered_set>
#include <cassert> #include <cassert>
#include <cfloat>
int main() int main()
{ {
@@ -35,7 +36,7 @@ int main()
P(80) P(80)
}; };
const C c(std::begin(a), std::end(a)); const C c(std::begin(a), std::end(a));
assert(c.load_factor() == (float)c.size() / c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
} }
{ {
typedef std::unordered_multiset<int> C; typedef std::unordered_multiset<int> C;

View File

@@ -17,6 +17,7 @@
#include <unordered_set> #include <unordered_set>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../test_compare.h" #include "../../../test_compare.h"
#include "../../../test_hash.h" #include "../../../test_hash.h"
@@ -74,7 +75,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
{ {
@@ -127,7 +128,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
} }

View File

@@ -17,6 +17,7 @@
#include <unordered_set> #include <unordered_set>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../test_compare.h" #include "../../../test_compare.h"
#include "../../../test_hash.h" #include "../../../test_hash.h"
@@ -54,7 +55,7 @@ int main()
assert(c.count(4) == 1); assert(c.count(4) == 1);
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS

View File

@@ -17,6 +17,7 @@
#include <unordered_set> #include <unordered_set>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../test_compare.h" #include "../../../test_compare.h"
#include "../../../test_hash.h" #include "../../../test_hash.h"
@@ -75,7 +76,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
{ {
@@ -120,7 +121,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
{ {
@@ -165,7 +166,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES

View File

@@ -17,6 +17,7 @@
#include <unordered_set> #include <unordered_set>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../test_compare.h" #include "../../../test_compare.h"
#include "../../../test_hash.h" #include "../../../test_hash.h"
@@ -67,7 +68,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE #ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
@@ -114,7 +115,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE #endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE

View File

@@ -17,6 +17,7 @@
#include <unordered_set> #include <unordered_set>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../test_compare.h" #include "../../../test_compare.h"
#include "../../../test_hash.h" #include "../../../test_hash.h"
@@ -67,7 +68,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
} }

View File

@@ -17,6 +17,7 @@
#include <unordered_set> #include <unordered_set>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../test_compare.h" #include "../../../test_compare.h"
#include "../../../test_hash.h" #include "../../../test_hash.h"
@@ -52,7 +53,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS

View File

@@ -17,6 +17,7 @@
#include <unordered_set> #include <unordered_set>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../test_compare.h" #include "../../../test_compare.h"
#include "../../../test_hash.h" #include "../../../test_hash.h"
@@ -54,7 +55,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS

View File

@@ -18,6 +18,7 @@
#include <unordered_set> #include <unordered_set>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../test_compare.h" #include "../../../test_compare.h"
#include "../../../test_hash.h" #include "../../../test_hash.h"
@@ -56,7 +57,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS

View File

@@ -18,6 +18,7 @@
#include <unordered_set> #include <unordered_set>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../test_compare.h" #include "../../../test_compare.h"
#include "../../../test_hash.h" #include "../../../test_hash.h"
@@ -57,7 +58,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS

View File

@@ -18,6 +18,7 @@
#include <unordered_set> #include <unordered_set>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../test_compare.h" #include "../../../test_compare.h"
#include "../../../test_hash.h" #include "../../../test_hash.h"
@@ -58,7 +59,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS

View File

@@ -17,6 +17,7 @@
#include <unordered_set> #include <unordered_set>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../test_compare.h" #include "../../../test_compare.h"
#include "../../../test_hash.h" #include "../../../test_hash.h"
@@ -95,7 +96,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
assert(c0.empty()); assert(c0.empty());

View File

@@ -17,6 +17,7 @@
#include <unordered_set> #include <unordered_set>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../test_compare.h" #include "../../../test_compare.h"
#include "../../../test_hash.h" #include "../../../test_hash.h"
@@ -69,7 +70,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
assert(c0.empty()); assert(c0.empty());
@@ -110,7 +111,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
assert(c0.empty()); assert(c0.empty());

View File

@@ -18,6 +18,7 @@
#include <unordered_set> #include <unordered_set>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../iterators.h" #include "../../../iterators.h"
#include "../../../test_compare.h" #include "../../../test_compare.h"
@@ -55,7 +56,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
} }

View File

@@ -18,6 +18,7 @@
#include <unordered_set> #include <unordered_set>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../iterators.h" #include "../../../iterators.h"
#include "../../../test_compare.h" #include "../../../test_compare.h"
@@ -57,7 +58,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
} }

View File

@@ -19,6 +19,7 @@
#include <unordered_set> #include <unordered_set>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../iterators.h" #include "../../../iterators.h"
#include "../../../test_compare.h" #include "../../../test_compare.h"
@@ -59,7 +60,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
} }

View File

@@ -19,6 +19,7 @@
#include <unordered_set> #include <unordered_set>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../iterators.h" #include "../../../iterators.h"
#include "../../../test_compare.h" #include "../../../test_compare.h"
@@ -60,7 +61,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
} }

View File

@@ -20,6 +20,7 @@
#include <unordered_set> #include <unordered_set>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../iterators.h" #include "../../../iterators.h"
#include "../../../test_compare.h" #include "../../../test_compare.h"
@@ -62,7 +63,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
} }

View File

@@ -17,6 +17,7 @@
#include <unordered_set> #include <unordered_set>
#include <cassert> #include <cassert>
#include <cfloat>
int main() int main()
{ {
@@ -35,7 +36,7 @@ int main()
P(80) P(80)
}; };
const C c(std::begin(a), std::end(a)); const C c(std::begin(a), std::end(a));
assert(c.load_factor() == (float)c.size() / c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
} }
{ {
typedef std::unordered_set<int> C; typedef std::unordered_set<int> C;

View File

@@ -17,6 +17,7 @@
#include <unordered_set> #include <unordered_set>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../test_compare.h" #include "../../../test_compare.h"
#include "../../../test_hash.h" #include "../../../test_hash.h"
@@ -66,7 +67,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
{ {
@@ -111,7 +112,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
} }

View File

@@ -17,6 +17,7 @@
#include <unordered_set> #include <unordered_set>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../test_compare.h" #include "../../../test_compare.h"
#include "../../../test_hash.h" #include "../../../test_hash.h"
@@ -54,7 +55,7 @@ int main()
assert(c.count(4) == 1); assert(c.count(4) == 1);
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS

View File

@@ -17,6 +17,7 @@
#include <unordered_set> #include <unordered_set>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../test_compare.h" #include "../../../test_compare.h"
#include "../../../test_hash.h" #include "../../../test_hash.h"
@@ -67,7 +68,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
{ {
@@ -112,7 +113,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
{ {
@@ -157,7 +158,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES

View File

@@ -17,6 +17,7 @@
#include <unordered_set> #include <unordered_set>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../test_compare.h" #include "../../../test_compare.h"
#include "../../../test_hash.h" #include "../../../test_hash.h"
@@ -59,7 +60,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE #ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
@@ -98,7 +99,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE #endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE

View File

@@ -17,6 +17,7 @@
#include <unordered_set> #include <unordered_set>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../test_compare.h" #include "../../../test_compare.h"
#include "../../../test_hash.h" #include "../../../test_hash.h"
@@ -59,7 +60,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
} }

View File

@@ -17,6 +17,7 @@
#include <unordered_set> #include <unordered_set>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../test_compare.h" #include "../../../test_compare.h"
#include "../../../test_hash.h" #include "../../../test_hash.h"
@@ -52,7 +53,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS

View File

@@ -17,6 +17,7 @@
#include <unordered_set> #include <unordered_set>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../test_compare.h" #include "../../../test_compare.h"
#include "../../../test_hash.h" #include "../../../test_hash.h"
@@ -54,7 +55,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS

View File

@@ -18,6 +18,7 @@
#include <unordered_set> #include <unordered_set>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../test_compare.h" #include "../../../test_compare.h"
#include "../../../test_hash.h" #include "../../../test_hash.h"
@@ -56,7 +57,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS

View File

@@ -18,6 +18,7 @@
#include <unordered_set> #include <unordered_set>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../test_compare.h" #include "../../../test_compare.h"
#include "../../../test_hash.h" #include "../../../test_hash.h"
@@ -57,7 +58,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS

View File

@@ -18,6 +18,7 @@
#include <unordered_set> #include <unordered_set>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../test_compare.h" #include "../../../test_compare.h"
#include "../../../test_hash.h" #include "../../../test_hash.h"
@@ -58,7 +59,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS

View File

@@ -17,6 +17,7 @@
#include <unordered_set> #include <unordered_set>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../test_compare.h" #include "../../../test_compare.h"
#include "../../../test_hash.h" #include "../../../test_hash.h"
@@ -95,7 +96,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
assert(c0.empty()); assert(c0.empty());

View File

@@ -17,6 +17,7 @@
#include <unordered_set> #include <unordered_set>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../test_compare.h" #include "../../../test_compare.h"
#include "../../../test_hash.h" #include "../../../test_hash.h"
@@ -61,7 +62,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
assert(c0.empty()); assert(c0.empty());
@@ -102,7 +103,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
assert(c0.empty()); assert(c0.empty());

View File

@@ -18,6 +18,7 @@
#include <unordered_set> #include <unordered_set>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../iterators.h" #include "../../../iterators.h"
#include "../../../test_compare.h" #include "../../../test_compare.h"
@@ -55,7 +56,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
} }

View File

@@ -18,6 +18,7 @@
#include <unordered_set> #include <unordered_set>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../iterators.h" #include "../../../iterators.h"
#include "../../../test_compare.h" #include "../../../test_compare.h"
@@ -57,7 +58,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
} }

View File

@@ -19,6 +19,7 @@
#include <unordered_set> #include <unordered_set>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../iterators.h" #include "../../../iterators.h"
#include "../../../test_compare.h" #include "../../../test_compare.h"
@@ -59,7 +60,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
} }

View File

@@ -19,6 +19,7 @@
#include <unordered_set> #include <unordered_set>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../iterators.h" #include "../../../iterators.h"
#include "../../../test_compare.h" #include "../../../test_compare.h"
@@ -60,7 +61,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
} }

View File

@@ -20,6 +20,7 @@
#include <unordered_set> #include <unordered_set>
#include <cassert> #include <cassert>
#include <cfloat>
#include "../../../iterators.h" #include "../../../iterators.h"
#include "../../../test_compare.h" #include "../../../test_compare.h"
@@ -62,7 +63,7 @@ int main()
assert(!c.empty()); assert(!c.empty());
assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.begin(), c.end()) == c.size());
assert(std::distance(c.cbegin(), c.cend()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size());
assert(c.load_factor() == (float)c.size()/c.bucket_count()); assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
assert(c.max_load_factor() == 1); assert(c.max_load_factor() == 1);
} }
} }