mirror of
https://github.com/llvm-mirror/libcxx.git
synced 2025-10-24 12:02:36 +08:00
Improve portability of hash tests. Patch from STL@microsoft.com
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@272744 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -16,12 +16,12 @@
|
|||||||
// size_t operator()(T val) const;
|
// size_t operator()(T val) const;
|
||||||
// };
|
// };
|
||||||
|
|
||||||
// Not very portable
|
|
||||||
|
|
||||||
#include <system_error>
|
#include <system_error>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
|
#include "test_macros.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
test(int i)
|
test(int i)
|
||||||
{
|
{
|
||||||
@@ -31,7 +31,9 @@ test(int i)
|
|||||||
static_assert((std::is_same<H::result_type, std::size_t>::value), "" );
|
static_assert((std::is_same<H::result_type, std::size_t>::value), "" );
|
||||||
H h;
|
H h;
|
||||||
T ec(i, std::system_category());
|
T ec(i, std::system_category());
|
||||||
assert(h(ec) == i);
|
const std::size_t result = h(ec);
|
||||||
|
LIBCPP_ASSERT(result == i);
|
||||||
|
((void)result); // Prevent unused warning
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
|
|||||||
@@ -16,12 +16,12 @@
|
|||||||
// size_t operator()(T val) const;
|
// size_t operator()(T val) const;
|
||||||
// };
|
// };
|
||||||
|
|
||||||
// Not very portable
|
|
||||||
|
|
||||||
#include <bitset>
|
#include <bitset>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
|
#include "test_macros.h"
|
||||||
|
|
||||||
template <std::size_t N>
|
template <std::size_t N>
|
||||||
void
|
void
|
||||||
test()
|
test()
|
||||||
@@ -32,7 +32,9 @@ test()
|
|||||||
static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" );
|
static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" );
|
||||||
H h;
|
H h;
|
||||||
T bs(static_cast<unsigned long long>(N));
|
T bs(static_cast<unsigned long long>(N));
|
||||||
assert(h(bs) == N);
|
const std::size_t result = h(bs);
|
||||||
|
LIBCPP_ASSERT(result == N);
|
||||||
|
((void)result); // Prevent unused warning
|
||||||
}
|
}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
|
|||||||
Reference in New Issue
Block a user