STL_MSFT created this revision.
STL_MSFT added reviewers: EricWF, mclow.lists.
STL_MSFT added a subscriber: cfe-commits.
Make unord.hash/integral.pass.cpp portable.
This was assuming identity hashing, which is a non-Standard assumption.
Guarding this with LIBCPP_ASSERT makes the test portable.
Also fixes MSVC warning C4805 "'==': unsafe mix of type '::size_t' and type
'bool' in operation".
http://reviews.llvm.org/D21583
Files:
test/std/utilities/function.objects/unord.hash/integral.pass.cpp
Index: test/std/utilities/function.objects/unord.hash/integral.pass.cpp
===================================================================
--- test/std/utilities/function.objects/unord.hash/integral.pass.cpp
+++ test/std/utilities/function.objects/unord.hash/integral.pass.cpp
@@ -16,14 +16,14 @@
// size_t operator()(T val) const;
// };
-// Not very portable
-
#include <functional>
#include <cassert>
#include <type_traits>
#include <cstddef>
#include <limits>
+#include "test_macros.h"
+
template <class T>
void
test()
@@ -37,7 +37,11 @@
{
T t(i);
if (sizeof(T) <= sizeof(std::size_t))
- assert(h(t) == t);
+ {
+ const std::size_t result = h(t);
+ LIBCPP_ASSERT(result == t);
+ ((void)result); // Prevent unused warning
+ }
}
}
Index: test/std/utilities/function.objects/unord.hash/integral.pass.cpp
===================================================================
--- test/std/utilities/function.objects/unord.hash/integral.pass.cpp
+++ test/std/utilities/function.objects/unord.hash/integral.pass.cpp
@@ -16,14 +16,14 @@
// size_t operator()(T val) const;
// };
-// Not very portable
-
#include <functional>
#include <cassert>
#include <type_traits>
#include <cstddef>
#include <limits>
+#include "test_macros.h"
+
template <class T>
void
test()
@@ -37,7 +37,11 @@
{
T t(i);
if (sizeof(T) <= sizeof(std::size_t))
- assert(h(t) == t);
+ {
+ const std::size_t result = h(t);
+ LIBCPP_ASSERT(result == t);
+ ((void)result); // Prevent unused warning
+ }
}
}
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits