STL_MSFT created this revision. STL_MSFT added reviewers: EricWF, mclow.lists. STL_MSFT added a subscriber: cfe-commits.
Improve portability of hash tests. These tests were expecting libcxx's identity-hash behavior, which isn't guaranteed by the Standard and isn't provided by MSVC (we currently use FNV-1a for everything). Marking the asserts as libcxx-specific and avoiding unused variable warnings for MSVC makes the tests portable. http://reviews.llvm.org/D21347 Files: test/std/diagnostics/syserr/syserr.hash/error_code.pass.cpp test/std/utilities/template.bitset/bitset.hash/bitset.pass.cpp Index: test/std/utilities/template.bitset/bitset.hash/bitset.pass.cpp =================================================================== --- test/std/utilities/template.bitset/bitset.hash/bitset.pass.cpp +++ test/std/utilities/template.bitset/bitset.hash/bitset.pass.cpp @@ -16,12 +16,12 @@ // size_t operator()(T val) const; // }; -// Not very portable - #include <bitset> #include <cassert> #include <type_traits> +#include "test_macros.h" + template <std::size_t N> void test() @@ -32,7 +32,9 @@ static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" ); H h; 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() Index: test/std/diagnostics/syserr/syserr.hash/error_code.pass.cpp =================================================================== --- test/std/diagnostics/syserr/syserr.hash/error_code.pass.cpp +++ test/std/diagnostics/syserr/syserr.hash/error_code.pass.cpp @@ -16,12 +16,12 @@ // size_t operator()(T val) const; // }; -// Not very portable - #include <system_error> #include <cassert> #include <type_traits> +#include "test_macros.h" + void test(int i) { @@ -31,7 +31,9 @@ static_assert((std::is_same<H::result_type, std::size_t>::value), "" ); H h; 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()
Index: test/std/utilities/template.bitset/bitset.hash/bitset.pass.cpp =================================================================== --- test/std/utilities/template.bitset/bitset.hash/bitset.pass.cpp +++ test/std/utilities/template.bitset/bitset.hash/bitset.pass.cpp @@ -16,12 +16,12 @@ // size_t operator()(T val) const; // }; -// Not very portable - #include <bitset> #include <cassert> #include <type_traits> +#include "test_macros.h" + template <std::size_t N> void test() @@ -32,7 +32,9 @@ static_assert((std::is_same<typename H::result_type, std::size_t>::value), "" ); H h; 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() Index: test/std/diagnostics/syserr/syserr.hash/error_code.pass.cpp =================================================================== --- test/std/diagnostics/syserr/syserr.hash/error_code.pass.cpp +++ test/std/diagnostics/syserr/syserr.hash/error_code.pass.cpp @@ -16,12 +16,12 @@ // size_t operator()(T val) const; // }; -// Not very portable - #include <system_error> #include <cassert> #include <type_traits> +#include "test_macros.h" + void test(int i) { @@ -31,7 +31,9 @@ static_assert((std::is_same<H::result_type, std::size_t>::value), "" ); H h; 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()
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits