diff options
Diffstat (limited to 'test/libcxx')
5 files changed, 232 insertions, 70 deletions
diff --git a/test/libcxx/experimental/containers/sequences/dynarray/dynarray.cons/default_throws_bad_alloc.pass.cpp b/test/libcxx/experimental/containers/sequences/dynarray/dynarray.cons/default_throws_bad_alloc.pass.cpp index 9c6cad8ee2d3..4009841355f9 100644 --- a/test/libcxx/experimental/containers/sequences/dynarray/dynarray.cons/default_throws_bad_alloc.pass.cpp +++ b/test/libcxx/experimental/containers/sequences/dynarray/dynarray.cons/default_throws_bad_alloc.pass.cpp @@ -16,7 +16,7 @@ // UNSUPPORTED: c++98, c++03, c++11 // The sanitizers replace new/delete with versions that do not throw bad_alloc. -// UNSUPPORTED: sanitizer-new-delete, ubsan +// UNSUPPORTED: sanitizer-new-delete #include <experimental/dynarray> diff --git a/test/libcxx/experimental/filesystem/convert_file_time.sh.cpp b/test/libcxx/experimental/filesystem/convert_file_time.sh.cpp new file mode 100644 index 000000000000..972d51813961 --- /dev/null +++ b/test/libcxx/experimental/filesystem/convert_file_time.sh.cpp @@ -0,0 +1,200 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11 + +// <experimental/filesystem> + +// typedef TrivialClock file_time_type; + +// RUN: %build -I%libcxx_src_root/src/experimental/filesystem +// RUN: %run + +#include <experimental/filesystem> +#include <chrono> +#include <type_traits> +#include <limits> +#include <cstddef> +#include <cassert> + +#include "filesystem_time_helper.h" + +using namespace std::chrono; +namespace fs = std::experimental::filesystem; +using fs::file_time_type; +using fs::fs_time_util; + +enum TestKind { TK_64Bit, TK_32Bit, TK_FloatingPoint }; + +template <class FileTimeT, class TimeT, class TimeSpec> +constexpr TestKind getTestKind() { + if (sizeof(TimeT) == 8 && !std::is_floating_point<TimeT>::value) + return TK_64Bit; + else if (sizeof(TimeT) == 4 && !std::is_floating_point<TimeT>::value) + return TK_32Bit; + else if (std::is_floating_point<TimeT>::value) + return TK_FloatingPoint; + else + assert(false && "test kind not supported"); +} + +template <class FileTimeT, class TimeT, class TimeSpecT, + class Base = fs_time_util<FileTimeT, TimeT, TimeSpecT>, + TestKind = getTestKind<FileTimeT, TimeT, TimeSpecT>()> +struct check_is_representable; + +template <class FileTimeT, class TimeT, class TimeSpecT, class Base> +struct check_is_representable<FileTimeT, TimeT, TimeSpecT, Base, TK_64Bit> + : public Base { + + using Base::convert_timespec; + using Base::is_representable; + using Base::max_nsec; + using Base::max_seconds; + using Base::min_nsec_timespec; + using Base::min_seconds; + + static constexpr auto max_time_t = std::numeric_limits<TimeT>::max(); + static constexpr auto min_time_t = std::numeric_limits<TimeT>::min(); + + static constexpr bool test_timespec() { + static_assert(is_representable(TimeSpecT{max_seconds, max_nsec}), ""); + static_assert(!is_representable(TimeSpecT{max_seconds + 1, 0}), ""); + static_assert(!is_representable(TimeSpecT{max_seconds, max_nsec + 1}), ""); + static_assert(!is_representable(TimeSpecT{max_time_t, 0}), ""); + static_assert(is_representable(TimeSpecT{min_seconds, 0}), ""); + static_assert( + is_representable(TimeSpecT{min_seconds - 1, min_nsec_timespec}), ""); + static_assert( + is_representable(TimeSpecT{min_seconds - 1, min_nsec_timespec + 1}), + ""); + static_assert( + !is_representable(TimeSpecT{min_seconds - 1, min_nsec_timespec - 1}), + ""); + static_assert(!is_representable(TimeSpecT{min_time_t, 999999999}), ""); + return true; + } + + static constexpr bool test_file_time_type() { + static_assert(Base::is_representable(FileTimeT::max()), ""); + static_assert(Base::is_representable(FileTimeT::min()), ""); + return true; + } + + static constexpr bool test_convert_timespec() { + static_assert(convert_timespec(TimeSpecT{max_seconds, max_nsec}) == + FileTimeT::max(), + ""); + static_assert(convert_timespec(TimeSpecT{max_seconds, max_nsec - 1}) < + FileTimeT::max(), + ""); + static_assert(convert_timespec(TimeSpecT{max_seconds - 1, 999999999}) < + FileTimeT::max(), + ""); + static_assert(convert_timespec(TimeSpecT{ + min_seconds - 1, min_nsec_timespec}) == FileTimeT::min(), + ""); + static_assert( + convert_timespec(TimeSpecT{min_seconds - 1, min_nsec_timespec + 1}) > + FileTimeT::min(), + ""); + static_assert( + convert_timespec(TimeSpecT{min_seconds, 0}) > FileTimeT::min(), ""); + return true; + } + + static bool test() { + static_assert(test_timespec(), ""); + static_assert(test_file_time_type(), ""); + static_assert(test_convert_timespec(), ""); + return true; + } +}; + +template <class FileTimeT, class TimeT, class TimeSpecT, class Base> +struct check_is_representable<FileTimeT, TimeT, TimeSpecT, Base, TK_32Bit> + : public Base { + static constexpr auto max_time_t = std::numeric_limits<TimeT>::max(); + static constexpr auto min_time_t = std::numeric_limits<TimeT>::min(); + + using Base::convert_timespec; + using Base::is_representable; + using Base::max_nsec; + using Base::max_seconds; + using Base::min_nsec_timespec; + using Base::min_seconds; + + static constexpr bool test_timespec() { + static_assert(is_representable(TimeSpecT{max_time_t, 999999999}), ""); + static_assert(is_representable(TimeSpecT{max_time_t, 1000000000}), ""); + static_assert(is_representable(TimeSpecT{min_time_t, 0}), ""); + return true; + } + + static constexpr bool test_file_time_type() { + static_assert(!is_representable(FileTimeT::max()), ""); + static_assert(!is_representable(FileTimeT::min()), ""); + static_assert(is_representable(FileTimeT(seconds(max_time_t))), ""); + static_assert(is_representable(FileTimeT(seconds(min_time_t))), ""); + return true; + } + + static constexpr bool test_convert_timespec() { + // FIXME add tests for 32 bit builds + return true; + } + + static bool test() { + static_assert(test_timespec(), ""); + static_assert(test_file_time_type(), ""); + static_assert(test_convert_timespec(), ""); + return true; + } +}; + +template <class FileTimeT, class TimeT, class TimeSpec, class Base> +struct check_is_representable<FileTimeT, TimeT, TimeSpec, Base, + TK_FloatingPoint> : public Base { + + static bool test() { return true; } +}; + +template <class TimeT, class NSecT = long> +struct TestTimeSpec { + TimeT tv_sec; + NSecT tv_nsec; +}; + +template <class Dur> +struct TestClock { + typedef Dur duration; + typedef typename duration::rep rep; + typedef typename duration::period period; + typedef std::chrono::time_point<TestClock> time_point; + static constexpr const bool is_steady = false; + + static time_point now() noexcept { return {}; } +}; + +template <class IntType, class Dur = duration<IntType, std::micro> > +using TestFileTimeT = time_point<TestClock<Dur> >; + +int main() { + assert(( + check_is_representable<file_time_type, time_t, struct timespec>::test())); + assert((check_is_representable<TestFileTimeT<int64_t>, int64_t, + TestTimeSpec<int64_t, long> >::test())); + assert((check_is_representable<TestFileTimeT<long long>, int32_t, + TestTimeSpec<int32_t, int32_t> >::test())); + + // Test that insane platforms like ppc64 linux, which use long double as time_t, + // at least compile. + assert((check_is_representable<TestFileTimeT<long double>, double, + TestTimeSpec<long double, long> >::test())); +} diff --git a/test/libcxx/numerics/c.math/constexpr-fns.pass.cpp b/test/libcxx/numerics/c.math/constexpr-fns.pass.cpp index 9123be1f0990..a58c389cd7ac 100644 --- a/test/libcxx/numerics/c.math/constexpr-fns.pass.cpp +++ b/test/libcxx/numerics/c.math/constexpr-fns.pass.cpp @@ -23,9 +23,9 @@ #include <cmath> -static_assert(std::__libcpp_isnan(0.) == false, ""); -static_assert(std::__libcpp_isinf(0.0) == false, ""); -static_assert(std::__libcpp_isfinite(0.0) == true, ""); +static_assert(std::__libcpp_isnan_or_builtin(0.) == false, ""); +static_assert(std::__libcpp_isinf_or_builtin(0.0) == false, ""); +static_assert(std::__libcpp_isfinite_or_builtin(0.0) == true, ""); int main() { diff --git a/test/libcxx/numerics/c.math/fdelayed-template-parsing.sh.cpp b/test/libcxx/numerics/c.math/fdelayed-template-parsing.sh.cpp new file mode 100644 index 000000000000..37aaa2acf1d9 --- /dev/null +++ b/test/libcxx/numerics/c.math/fdelayed-template-parsing.sh.cpp @@ -0,0 +1,28 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// test that cmath builds with -fdelayed-template-parsing + +// REQUIRES: fdelayed-template-parsing + +// RUN: %build -fdelayed-template-parsing +// RUN: %run + +#include <cmath> +#include <cassert> + +#include "test_macros.h" + +int main() { + assert(std::isfinite(1.0)); + assert(!std::isinf(1.0)); + assert(!std::isnan(1.0)); +} + +using namespace std; diff --git a/test/libcxx/utilities/optional/optional.object/special_member_gen.pass.cpp b/test/libcxx/utilities/optional/optional.object/special_member_gen.pass.cpp deleted file mode 100644 index 9493d6bb766c..000000000000 --- a/test/libcxx/utilities/optional/optional.object/special_member_gen.pass.cpp +++ /dev/null @@ -1,66 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// UNSUPPORTED: c++98, c++03, c++11, c++14 -// <optional> - - -#include <optional> -#include <type_traits> -#include <cassert> - -#include "archetypes.hpp" - -template <class T> -struct SpecialMemberTest { - using O = std::optional<T>; - - template <template <class> class TestMF> - static constexpr bool check_same() { - return TestMF<O>::value == TestMF<T>::value; - } - - // Test that optional inherits the correct trivial/non-trivial members - static_assert(check_same<std::is_trivially_destructible>(), ""); - static_assert(check_same<std::is_trivially_copyable>(), ""); -}; - -template <class ...Args> static void sink(Args&&...) {} - -template <class ...TestTypes> -struct DoTestsMetafunction { - DoTestsMetafunction() { sink(SpecialMemberTest<TestTypes>{}...); } -}; - -struct TrivialMoveNonTrivialCopy { - TrivialMoveNonTrivialCopy() = default; - TrivialMoveNonTrivialCopy(const TrivialMoveNonTrivialCopy&) {} - TrivialMoveNonTrivialCopy(TrivialMoveNonTrivialCopy&&) = default; - TrivialMoveNonTrivialCopy& operator=(const TrivialMoveNonTrivialCopy&) { return *this; } - TrivialMoveNonTrivialCopy& operator=(TrivialMoveNonTrivialCopy&&) = default; -}; - -struct TrivialCopyNonTrivialMove { - TrivialCopyNonTrivialMove() = default; - TrivialCopyNonTrivialMove(const TrivialCopyNonTrivialMove&) = default; - TrivialCopyNonTrivialMove(TrivialCopyNonTrivialMove&&) {} - TrivialCopyNonTrivialMove& operator=(const TrivialCopyNonTrivialMove&) = default; - TrivialCopyNonTrivialMove& operator=(TrivialCopyNonTrivialMove&&) { return *this; } -}; - -int main() -{ - sink( - ImplicitTypes::ApplyTypes<DoTestsMetafunction>{}, - ExplicitTypes::ApplyTypes<DoTestsMetafunction>{}, - NonLiteralTypes::ApplyTypes<DoTestsMetafunction>{}, - NonTrivialTypes::ApplyTypes<DoTestsMetafunction>{}, - DoTestsMetafunction<TrivialMoveNonTrivialCopy, TrivialCopyNonTrivialMove>{} - ); -} |