aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/CMakeLists.txt33
-rw-r--r--test/libcxx/experimental/containers/sequences/dynarray/dynarray.cons/default_throws_bad_alloc.pass.cpp2
-rw-r--r--test/libcxx/experimental/filesystem/convert_file_time.sh.cpp200
-rw-r--r--test/libcxx/numerics/c.math/constexpr-fns.pass.cpp6
-rw-r--r--test/libcxx/numerics/c.math/fdelayed-template-parsing.sh.cpp28
-rw-r--r--test/libcxx/utilities/optional/optional.object/special_member_gen.pass.cpp66
-rw-r--r--test/std/atomics/atomics.lockfree/isalwayslockfree.pass.cpp37
-rw-r--r--test/std/experimental/filesystem/fs.op.funcs/fs.op.equivalent/equivalent.pass.cpp126
-rw-r--r--test/std/re/re.iter/re.regiter/re.regiter.incr/post.pass.cpp18
-rw-r--r--test/std/thread/futures/futures.task/futures.task.members/ctor2.fail.cpp2
-rw-r--r--test/std/utilities/memory/default.allocator/allocator.members/allocate.pass.cpp5
-rw-r--r--test/std/utilities/optional/optional.object/optional.object.assign/move.pass.cpp30
-rw-r--r--test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp8
-rw-r--r--test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp8
-rw-r--r--test/std/utilities/optional/optional.object/special_member_gen.pass.cpp36
15 files changed, 452 insertions, 153 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 6f2eac0546fc..7b8a8322a11f 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -85,3 +85,36 @@ if (LIBCXX_GENERATE_COVERAGE)
set(extract_dirs "${LIBCXX_SOURCE_DIR}/include;${LIBCXX_SOURCE_DIR}/src")
setup_lcov_test_target_coverage("cxx" "${output_dir}" "${capture_dirs}" "${extract_dirs}")
endif()
+
+
+if (LIBCXX_CONFIGURE_IDE)
+ # Create dummy targets for each of the tests in the test suite, this allows
+ # IDE's such as CLion to correctly highlight the tests because it knows
+ # roughly what include paths/compile flags/macro definitions are needed.
+ include_directories(support)
+ file(GLOB_RECURSE LIBCXX_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/*.pass.cpp)
+ file(GLOB LIBCXX_TEST_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/support/*)
+ file(GLOB_RECURSE LIBCXX_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/../include/*)
+ add_executable(libcxx_test_objects EXCLUDE_FROM_ALL
+ ${LIBCXX_TESTS} ${LIBCXX_TEST_HEADERS} ${LIBCXX_HEADERS})
+ add_dependencies(libcxx_test_objects cxx)
+
+ set(STATIC_ROOT ${LIBCXX_SOURCE_DIR}/test/std/experimental/filesystem/Inputs/static_test_env)
+ add_definitions(-DLIBCXX_FILESYSTEM_STATIC_TEST_ROOT="${STATIC_ROOT}")
+
+ set(DYNAMIC_ROOT ${LIBCXX_BINARY_DIR}/test/filesystem/Output/dynamic_env)
+ add_definitions(-DLIBCXX_FILESYSTEM_DYNAMIC_TEST_ROOT="${DYNAMIC_ROOT}")
+
+ set(DYNAMIC_HELPER "python ${LIBCXX_SOURCE_DIR}/test/support/filesystem_dynamic_test_helper.py ")
+ add_definitions(-DLIBCXX_FILESYSTEM_DYNAMIC_TEST_HELPER="${DYNAMIC_HELPER}")
+
+ split_list(LIBCXX_COMPILE_FLAGS)
+ split_list(LIBCXX_LINK_FLAGS)
+
+ set_target_properties(libcxx_test_objects
+ PROPERTIES
+ COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}"
+ LINK_FLAGS "${LIBCXX_LINK_FLAGS}"
+ EXCLUDE_FROM_ALL ON
+ )
+endif()
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>{}
- );
-}
diff --git a/test/std/atomics/atomics.lockfree/isalwayslockfree.pass.cpp b/test/std/atomics/atomics.lockfree/isalwayslockfree.pass.cpp
index e42e9f28448a..7a4090b9c252 100644
--- a/test/std/atomics/atomics.lockfree/isalwayslockfree.pass.cpp
+++ b/test/std/atomics/atomics.lockfree/isalwayslockfree.pass.cpp
@@ -25,6 +25,40 @@ template <typename T> void checkAlwaysLockFree() {
assert(std::atomic<T>().is_lock_free());
}
+// FIXME: This separate test is needed to work around llvm.org/PR31864
+// which causes ATOMIC_LLONG_LOCK_FREE to be defined as '1' in 32-bit builds
+// even though __atomic_always_lock_free returns true for the same type.
+constexpr bool NeedWorkaroundForPR31864 =
+#if defined(__clang__)
+(sizeof(void*) == 4); // Needed on 32 bit builds
+#else
+false;
+#endif
+
+template <bool Disable = NeedWorkaroundForPR31864,
+ std::enable_if_t<!Disable>* = nullptr,
+ class LLong = long long,
+ class ULLong = unsigned long long>
+void checkLongLongTypes() {
+ static_assert(std::atomic<LLong>::is_always_lock_free == (2 == ATOMIC_LLONG_LOCK_FREE));
+ static_assert(std::atomic<ULLong>::is_always_lock_free == (2 == ATOMIC_LLONG_LOCK_FREE));
+}
+
+// Used to make the calls to __atomic_always_lock_free dependent on a template
+// parameter.
+template <class T> constexpr size_t getSizeOf() { return sizeof(T); }
+
+template <bool Enable = NeedWorkaroundForPR31864,
+ std::enable_if_t<Enable>* = nullptr,
+ class LLong = long long,
+ class ULLong = unsigned long long>
+void checkLongLongTypes() {
+ constexpr bool ExpectLockFree = __atomic_always_lock_free(getSizeOf<LLong>(), 0);
+ static_assert(std::atomic<LLong>::is_always_lock_free == ExpectLockFree, "");
+ static_assert(std::atomic<ULLong>::is_always_lock_free == ExpectLockFree, "");
+ static_assert((0 != ATOMIC_LLONG_LOCK_FREE) == ExpectLockFree, "");
+}
+
int main()
{
// structs and unions can't be defined in the template invocation.
@@ -94,8 +128,7 @@ int main()
static_assert(std::atomic<unsigned int>::is_always_lock_free == (2 == ATOMIC_INT_LOCK_FREE));
static_assert(std::atomic<long>::is_always_lock_free == (2 == ATOMIC_LONG_LOCK_FREE));
static_assert(std::atomic<unsigned long>::is_always_lock_free == (2 == ATOMIC_LONG_LOCK_FREE));
- static_assert(std::atomic<long long>::is_always_lock_free == (2 == ATOMIC_LLONG_LOCK_FREE));
- static_assert(std::atomic<unsigned long long>::is_always_lock_free == (2 == ATOMIC_LLONG_LOCK_FREE));
+ checkLongLongTypes();
static_assert(std::atomic<void*>::is_always_lock_free == (2 == ATOMIC_POINTER_LOCK_FREE));
static_assert(std::atomic<std::nullptr_t>::is_always_lock_free == (2 == ATOMIC_POINTER_LOCK_FREE));
}
diff --git a/test/std/experimental/filesystem/fs.op.funcs/fs.op.equivalent/equivalent.pass.cpp b/test/std/experimental/filesystem/fs.op.funcs/fs.op.equivalent/equivalent.pass.cpp
index 621ff8305fc3..a3591e0267e6 100644
--- a/test/std/experimental/filesystem/fs.op.funcs/fs.op.equivalent/equivalent.pass.cpp
+++ b/test/std/experimental/filesystem/fs.op.funcs/fs.op.equivalent/equivalent.pass.cpp
@@ -26,63 +26,87 @@ using namespace std::experimental::filesystem;
TEST_SUITE(equivalent_test_suite)
-TEST_CASE(signature_test)
-{
- const path p; ((void)p);
- std::error_code ec; ((void)ec);
- ASSERT_NOEXCEPT(equivalent(p, p, ec));
- ASSERT_NOT_NOEXCEPT(equivalent(p, p));
+TEST_CASE(signature_test) {
+ const path p;
+ ((void)p);
+ std::error_code ec;
+ ((void)ec);
+ ASSERT_NOEXCEPT(equivalent(p, p, ec));
+ ASSERT_NOT_NOEXCEPT(equivalent(p, p));
}
-TEST_CASE(equivalent_test)
-{
- struct TestCase {
- path lhs;
- path rhs;
- bool expect;
- };
- const TestCase testCases[] = {
- {StaticEnv::Dir, StaticEnv::Dir, true},
- {StaticEnv::File, StaticEnv::Dir, false},
- {StaticEnv::Dir, StaticEnv::SymlinkToDir, true},
- {StaticEnv::Dir, StaticEnv::SymlinkToFile, false},
- {StaticEnv::File, StaticEnv::File, true},
- {StaticEnv::File, StaticEnv::SymlinkToFile, true},
- };
- for (auto& TC : testCases) {
- std::error_code ec;
- TEST_CHECK(equivalent(TC.lhs, TC.rhs, ec) == TC.expect);
- TEST_CHECK(!ec);
- }
+TEST_CASE(equivalent_test) {
+ struct TestCase {
+ path lhs;
+ path rhs;
+ bool expect;
+ };
+ const TestCase testCases[] = {
+ {StaticEnv::Dir, StaticEnv::Dir, true},
+ {StaticEnv::File, StaticEnv::Dir, false},
+ {StaticEnv::Dir, StaticEnv::SymlinkToDir, true},
+ {StaticEnv::Dir, StaticEnv::SymlinkToFile, false},
+ {StaticEnv::File, StaticEnv::File, true},
+ {StaticEnv::File, StaticEnv::SymlinkToFile, true},
+ };
+ for (auto& TC : testCases) {
+ std::error_code ec;
+ TEST_CHECK(equivalent(TC.lhs, TC.rhs, ec) == TC.expect);
+ TEST_CHECK(!ec);
+ }
}
-TEST_CASE(equivalent_reports_double_dne)
-{
- const path E = StaticEnv::File;
- const path DNE = StaticEnv::DNE;
- { // Test that no exception is thrown if one of the paths exists
- TEST_CHECK(equivalent(E, DNE) == false);
- TEST_CHECK(equivalent(DNE, E) == false);
- }
- { // Test that an exception is thrown if both paths do not exist.
- TEST_CHECK_THROW(filesystem_error, equivalent(DNE, DNE));
- }
- {
- std::error_code ec;
- TEST_CHECK(equivalent(DNE, DNE, ec) == false);
- TEST_CHECK(ec);
- }
+TEST_CASE(equivalent_reports_error_if_input_dne) {
+ const path E = StaticEnv::File;
+ const path DNE = StaticEnv::DNE;
+ { // Test that an error is reported when either of the paths don't exist
+ std::error_code ec = GetTestEC();
+ TEST_CHECK(equivalent(E, DNE, ec) == false);
+ TEST_CHECK(ec);
+ TEST_CHECK(ec != GetTestEC());
+ }
+ {
+ std::error_code ec = GetTestEC();
+ TEST_CHECK(equivalent(DNE, E, ec) == false);
+ TEST_CHECK(ec);
+ TEST_CHECK(ec != GetTestEC());
+ }
+ {
+ TEST_CHECK_THROW(filesystem_error, equivalent(DNE, E));
+ TEST_CHECK_THROW(filesystem_error, equivalent(E, DNE));
+ }
+ { // Test that an exception is thrown if both paths do not exist.
+ TEST_CHECK_THROW(filesystem_error, equivalent(DNE, DNE));
+ }
+ {
+ std::error_code ec = GetTestEC();
+ TEST_CHECK(equivalent(DNE, DNE, ec) == false);
+ TEST_CHECK(ec);
+ TEST_CHECK(ec != GetTestEC());
+ }
}
-TEST_CASE(equivalent_is_other_succeeds)
-{
- scoped_test_env env;
- path const file = env.create_file("file", 42);
- const path hl1 = env.create_hardlink(file, "hl1");
- const path hl2 = env.create_hardlink(file, "hl2");
- TEST_CHECK(equivalent(file, hl1));
- TEST_CHECK(equivalent(file, hl2));
- TEST_CHECK(equivalent(hl1, hl2));
+TEST_CASE(equivalent_hardlink_succeeds) {
+ scoped_test_env env;
+ path const file = env.create_file("file", 42);
+ const path hl1 = env.create_hardlink(file, "hl1");
+ const path hl2 = env.create_hardlink(file, "hl2");
+ TEST_CHECK(equivalent(file, hl1));
+ TEST_CHECK(equivalent(file, hl2));
+ TEST_CHECK(equivalent(hl1, hl2));
+}
+
+TEST_CASE(equivalent_is_other_succeeds) {
+ scoped_test_env env;
+ path const file = env.create_file("file", 42);
+ const path fifo1 = env.create_fifo("fifo1");
+ const path fifo2 = env.create_fifo("fifo2");
+ // Required to test behavior for inputs where is_other(p) is true.
+ TEST_REQUIRE(is_other(fifo1));
+ TEST_CHECK(!equivalent(file, fifo1));
+ TEST_CHECK(!equivalent(fifo2, file));
+ TEST_CHECK(!equivalent(fifo1, fifo2));
+ TEST_CHECK(equivalent(fifo1, fifo1));
}
TEST_SUITE_END()
diff --git a/test/std/re/re.iter/re.regiter/re.regiter.incr/post.pass.cpp b/test/std/re/re.iter/re.regiter/re.regiter.incr/post.pass.cpp
index f3b57f6bc9da..5e3ad4d910e7 100644
--- a/test/std/re/re.iter/re.regiter/re.regiter.incr/post.pass.cpp
+++ b/test/std/re/re.iter/re.regiter/re.regiter.incr/post.pass.cpp
@@ -95,4 +95,22 @@ int main()
assert((*i2).position() == 0);
assert((*i2).str() == "555-1234");
}
+ { // http://llvm.org/PR33681
+ std::regex rex(".*");
+ const char foo[] = "foo";
+ // The -1 is because we don't want the implicit null from the array.
+ std::cregex_iterator i(std::begin(foo), std::end(foo) - 1, rex);
+ std::cregex_iterator e;
+ assert(i != e);
+ assert((*i).size() == 1);
+ assert((*i).str() == "foo");
+
+ ++i;
+ assert(i != e);
+ assert((*i).size() == 1);
+ assert((*i).str() == "");
+
+ ++i;
+ assert(i == e);
+ }
}
diff --git a/test/std/thread/futures/futures.task/futures.task.members/ctor2.fail.cpp b/test/std/thread/futures/futures.task/futures.task.members/ctor2.fail.cpp
index 984dcdc80b32..212a12084e79 100644
--- a/test/std/thread/futures/futures.task/futures.task.members/ctor2.fail.cpp
+++ b/test/std/thread/futures/futures.task/futures.task.members/ctor2.fail.cpp
@@ -30,5 +30,5 @@ typedef volatile std::packaged_task<A(int, char)> VPT;
int main()
{
PT p { std::allocator_arg_t{}, test_allocator<A>{}, VPT {}}; // expected-error {{no matching constructor for initialization of 'PT' (aka 'packaged_task<A (int, char)>')}}
- // expected-note@future:* 1 {{candidate template ignored: disabled by 'enable_if'}}
+ // expected-note-re@future:* 1 {{candidate template ignored: {{(disabled by 'enable_if')|(requirement '.*' was not satisfied)}}}}
}
diff --git a/test/std/utilities/memory/default.allocator/allocator.members/allocate.pass.cpp b/test/std/utilities/memory/default.allocator/allocator.members/allocate.pass.cpp
index 253515e3db3c..f2cf9f2d4187 100644
--- a/test/std/utilities/memory/default.allocator/allocator.members/allocate.pass.cpp
+++ b/test/std/utilities/memory/default.allocator/allocator.members/allocate.pass.cpp
@@ -29,11 +29,12 @@ struct A
int main()
{
+ globalMemCounter.reset();
std::allocator<A> a;
assert(globalMemCounter.checkOutstandingNewEq(0));
assert(A_constructed == 0);
globalMemCounter.last_new_size = 0;
- A* ap = a.allocate(3);
+ A* volatile ap = a.allocate(3);
assert(globalMemCounter.checkOutstandingNewEq(1));
assert(globalMemCounter.checkLastNewSizeEq(3 * sizeof(int)));
assert(A_constructed == 0);
@@ -42,7 +43,7 @@ int main()
assert(A_constructed == 0);
globalMemCounter.last_new_size = 0;
- A* ap2 = a.allocate(3, (const void*)5);
+ A* volatile ap2 = a.allocate(3, (const void*)5);
assert(globalMemCounter.checkOutstandingNewEq(1));
assert(globalMemCounter.checkLastNewSizeEq(3 * sizeof(int)));
assert(A_constructed == 0);
diff --git a/test/std/utilities/optional/optional.object/optional.object.assign/move.pass.cpp b/test/std/utilities/optional/optional.object/optional.object.assign/move.pass.cpp
index 3ba261b52464..ed8b433da693 100644
--- a/test/std/utilities/optional/optional.object/optional.object.assign/move.pass.cpp
+++ b/test/std/utilities/optional/optional.object/optional.object.assign/move.pass.cpp
@@ -147,27 +147,27 @@ int main()
}
{
struct ThrowsMove {
- ThrowsMove() noexcept {}
- ThrowsMove(ThrowsMove const&) noexcept {}
- ThrowsMove(ThrowsMove &&) noexcept(false) {}
- ThrowsMove& operator=(ThrowsMove const&) noexcept { return *this; }
- ThrowsMove& operator=(ThrowsMove &&) noexcept { return *this; }
+ ThrowsMove() noexcept {}
+ ThrowsMove(ThrowsMove const&) noexcept {}
+ ThrowsMove(ThrowsMove &&) noexcept(false) {}
+ ThrowsMove& operator=(ThrowsMove const&) noexcept { return *this; }
+ ThrowsMove& operator=(ThrowsMove &&) noexcept { return *this; }
};
static_assert(!std::is_nothrow_move_assignable<optional<ThrowsMove>>::value, "");
struct ThrowsMoveAssign {
- ThrowsMoveAssign() noexcept {}
- ThrowsMoveAssign(ThrowsMoveAssign const&) noexcept {}
- ThrowsMoveAssign(ThrowsMoveAssign &&) noexcept {}
- ThrowsMoveAssign& operator=(ThrowsMoveAssign const&) noexcept { return *this; }
- ThrowsMoveAssign& operator=(ThrowsMoveAssign &&) noexcept(false) { return *this; }
+ ThrowsMoveAssign() noexcept {}
+ ThrowsMoveAssign(ThrowsMoveAssign const&) noexcept {}
+ ThrowsMoveAssign(ThrowsMoveAssign &&) noexcept {}
+ ThrowsMoveAssign& operator=(ThrowsMoveAssign const&) noexcept { return *this; }
+ ThrowsMoveAssign& operator=(ThrowsMoveAssign &&) noexcept(false) { return *this; }
};
static_assert(!std::is_nothrow_move_assignable<optional<ThrowsMoveAssign>>::value, "");
struct NoThrowMove {
- NoThrowMove() noexcept(false) {}
- NoThrowMove(NoThrowMove const&) noexcept(false) {}
- NoThrowMove(NoThrowMove &&) noexcept {}
- NoThrowMove& operator=(NoThrowMove const&) noexcept { return *this; }
- NoThrowMove& operator=(NoThrowMove&&) noexcept { return *this; }
+ NoThrowMove() noexcept(false) {}
+ NoThrowMove(NoThrowMove const&) noexcept(false) {}
+ NoThrowMove(NoThrowMove &&) noexcept {}
+ NoThrowMove& operator=(NoThrowMove const&) noexcept { return *this; }
+ NoThrowMove& operator=(NoThrowMove&&) noexcept { return *this; }
};
static_assert(std::is_nothrow_move_assignable<optional<NoThrowMove>>::value, "");
}
diff --git a/test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp b/test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp
index 6b4283a2854b..0f1fabd0cebb 100644
--- a/test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp
+++ b/test/std/utilities/optional/optional.object/optional.object.ctor/copy.pass.cpp
@@ -45,10 +45,10 @@ constexpr bool constexpr_test(InitArgs&&... args)
void test_throwing_ctor() {
#ifndef TEST_HAS_NO_EXCEPTIONS
struct Z {
- Z() : count(0) {}
- Z(Z const& o) : count(o.count + 1)
- { if (count == 2) throw 6; }
- int count;
+ Z() : count(0) {}
+ Z(Z const& o) : count(o.count + 1)
+ { if (count == 2) throw 6; }
+ int count;
};
const Z z;
const optional<Z> rhs(z);
diff --git a/test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp b/test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp
index 55c2156300fb..e73f3747c435 100644
--- a/test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp
+++ b/test/std/utilities/optional/optional.object/optional.object.ctor/move.pass.cpp
@@ -55,10 +55,10 @@ constexpr bool constexpr_test(InitArgs&&... args)
void test_throwing_ctor() {
#ifndef TEST_HAS_NO_EXCEPTIONS
struct Z {
- Z() : count(0) {}
- Z(Z&& o) : count(o.count + 1)
- { if (count == 2) throw 6; }
- int count;
+ Z() : count(0) {}
+ Z(Z&& o) : count(o.count + 1)
+ { if (count == 2) throw 6; }
+ int count;
};
Z z;
optional<Z> rhs(std::move(z));
diff --git a/test/std/utilities/optional/optional.object/special_member_gen.pass.cpp b/test/std/utilities/optional/optional.object/special_member_gen.pass.cpp
index fdd0f154f0e5..0b9b6e717c3a 100644
--- a/test/std/utilities/optional/optional.object/special_member_gen.pass.cpp
+++ b/test/std/utilities/optional/optional.object/special_member_gen.pass.cpp
@@ -33,10 +33,38 @@ struct SpecialMemberTest {
"optional<T> is copy assignable if and only if T is both copy "
"constructible and copy assignable.");
static_assert(std::is_move_assignable_v<O> ==
- ((std::is_copy_constructible_v<T> && std::is_copy_assignable_v<T>) ||
- (std::is_move_constructible_v<T> && std::is_move_assignable_v<T>)),
- "optional<T> is move assignable if and only if T is both move assignable and "
- "move constructible, or both copy constructible and copy assignable.");
+ ((std::is_move_constructible_v<T> && std::is_move_assignable_v<T>) ||
+ (std::is_copy_constructible_v<T> && std::is_copy_assignable_v<T>)),
+ "optional<T> is move assignable if and only if T is both move constructible and "
+ "move assignable, or both copy constructible and copy assignable.");
+
+ // The following tests are for not-yet-standardized behavior (P0602):
+ static_assert(std::is_trivially_destructible_v<O> ==
+ std::is_trivially_destructible_v<T>,
+ "optional<T> is trivially destructible if and only if T is.");
+ static_assert(std::is_trivially_copy_constructible_v<O> ==
+ std::is_trivially_copy_constructible_v<T>,
+ "optional<T> is trivially copy constructible if and only if T is.");
+ static_assert(std::is_trivially_move_constructible_v<O> ==
+ std::is_trivially_move_constructible_v<T> ||
+ (!std::is_move_constructible_v<T> && std::is_trivially_copy_constructible_v<T>),
+ "optional<T> is trivially move constructible if T is trivially move constructible, "
+ "or if T is trivially copy constructible and is not move constructible.");
+ static_assert(std::is_trivially_copy_assignable_v<O> ==
+ (std::is_trivially_destructible_v<T> &&
+ std::is_trivially_copy_constructible_v<T> &&
+ std::is_trivially_copy_assignable_v<T>),
+ "optional<T> is trivially copy assignable if and only if T is trivially destructible, "
+ "trivially copy constructible, and trivially copy assignable.");
+ static_assert(std::is_trivially_move_assignable_v<O> ==
+ (std::is_trivially_destructible_v<T> &&
+ ((std::is_trivially_move_constructible_v<T> && std::is_trivially_move_assignable_v<T>) ||
+ ((!std::is_move_constructible_v<T> || !std::is_move_assignable_v<T>) &&
+ std::is_trivially_copy_constructible_v<T> && std::is_trivially_copy_assignable_v<T>))),
+ "optional<T> is trivially move assignable if T is trivially destructible, and either "
+ "(1) trivially move constructible and trivially move assignable, or "
+ "(2) not move constructible or not move assignable, and "
+ "trivially copy constructible and trivially copy assignable.");
};
template <class ...Args> static void sink(Args&&...) {}