Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanups: Test code using ranges as an identifier, plus more #3528

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions tests/std/tests/Dev09_056375_locale_cleanup/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ void test_dll() {
as->GetType("Test")->GetMethod("DllTest")->Invoke(nullptr, nullptr);
AppDomain::Unload(ad);
}
#else
#else // ^^^ defined(_M_CEE) / !defined(_M_CEE) vvv
HMODULE hLibrary = LoadLibraryExW(L"testdll.dll", nullptr, 0);
assert(hLibrary != nullptr);
typedef void (*TheFuncProc)();
TheFuncProc pFunc = (TheFuncProc) GetProcAddress(hLibrary, "DllTest");
TheFuncProc pFunc = reinterpret_cast<TheFuncProc>(GetProcAddress(hLibrary, "DllTest"));
assert(pFunc != nullptr);
pFunc();
FreeLibrary(hLibrary);
#endif
#endif // ^^^ !defined(_M_CEE) ^^^
}

void test_exe_part1() {
Expand All @@ -51,9 +51,6 @@ void test_exe_part2() {
}

int main() {
#ifdef _M_CEE
using namespace System;
#endif
test_exe_part1();
test_dll();
test_exe_part2();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,10 @@ int main() {
test_distribution(piecewise_constant_distribution<float>(begin(rangesf), end(rangesf), begin(weightsf)));
test_distribution(piecewise_linear_distribution<float>(begin(rangesf), end(rangesf), begin(weightsf)));

vector<double> ranges{0.0, 10.0, 90.0, 100.0};
vector<double> weights{1.0, 0.0, 0.0, 1.0};
test_distribution(piecewise_constant_distribution<double>(begin(ranges), end(ranges), begin(weights)));
test_distribution(piecewise_linear_distribution<double>(begin(ranges), end(ranges), begin(weights)));
vector<double> rangesd{0.0, 10.0, 90.0, 100.0};
vector<double> weightsd{1.0, 0.0, 0.0, 1.0};
test_distribution(piecewise_constant_distribution<double>(begin(rangesd), end(rangesd), begin(weightsd)));
test_distribution(piecewise_linear_distribution<double>(begin(rangesd), end(rangesd), begin(weightsd)));

vector<long double> rangesl{0.0l, 10.0l, 90.0l, 100.0l};
vector<long double> weightsl{1.0l, 0.0l, 0.0l, 1.0l};
Expand Down
22 changes: 11 additions & 11 deletions tests/std/tests/P2321R2_views_zip/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
using namespace std;

template <class... RangeTypes>
concept CanViewZip = requires(RangeTypes&&... ranges) { views::zip(std::forward<RangeTypes>(ranges)...); };
concept CanViewZip = requires(RangeTypes&&... rngs) { views::zip(std::forward<RangeTypes>(rngs)...); };

template <class RangeType>
using AllView = views::all_t<RangeType>;
Expand Down Expand Up @@ -226,7 +226,7 @@ constexpr bool do_tuples_reference_same_objects(const LHSTupleType& lhs_tuple, c
#pragma warning(disable : 4100) // unreferenced formal parameter

template <class TestContainerType, ranges::input_range... RangeTypes>
constexpr bool test_one(TestContainerType& test_container, RangeTypes&&... ranges) {
constexpr bool test_one(TestContainerType& test_container, RangeTypes&&... rngs) {
// Ignore instances where one of the generated test ranges does not model
// ranges::viewable_range.
if constexpr ((ranges::viewable_range<RangeTypes&> && ...)) {
Expand Down Expand Up @@ -258,8 +258,8 @@ constexpr bool test_one(TestContainerType& test_container, RangeTypes&&... range
using ExpectedZipType = ZipType;
constexpr bool is_noexcept = (is_nothrow_copy_constructible_v<AllView<RangeTypes>> && ...);

STATIC_ASSERT(same_as<decltype(views::zip(ranges...)), ExpectedZipType>);
STATIC_ASSERT(noexcept(views::zip(ranges...)) == is_noexcept);
STATIC_ASSERT(same_as<decltype(views::zip(rngs...)), ExpectedZipType>);
STATIC_ASSERT(noexcept(views::zip(rngs...)) == is_noexcept);
}

// ... with const lvalue arguments
Expand All @@ -269,8 +269,8 @@ constexpr bool test_one(TestContainerType& test_container, RangeTypes&&... range
using ExpectedZipType = ranges::zip_view<AllView<const remove_reference_t<RangeTypes>&>...>;
constexpr bool is_noexcept = (is_nothrow_copy_constructible_v<AllView<RangeTypes>> && ...);

STATIC_ASSERT(same_as<decltype(views::zip(as_const(ranges)...)), ExpectedZipType>);
STATIC_ASSERT(noexcept(views::zip(as_const(ranges)...)) == is_noexcept);
STATIC_ASSERT(same_as<decltype(views::zip(as_const(rngs)...)), ExpectedZipType>);
STATIC_ASSERT(noexcept(views::zip(as_const(rngs)...)) == is_noexcept);
}

// ... with rvalue argument
Expand All @@ -280,8 +280,8 @@ constexpr bool test_one(TestContainerType& test_container, RangeTypes&&... range
using ExpectedZipType = ranges::zip_view<AllView<remove_reference_t<RangeTypes>>...>;
constexpr bool is_noexcept = (is_nothrow_move_constructible_v<AllView<RangeTypes>> && ...);

STATIC_ASSERT(same_as<decltype(views::zip(std::move(ranges)...)), ExpectedZipType>);
STATIC_ASSERT(noexcept(views::zip(std::move(ranges)...)) == is_noexcept);
STATIC_ASSERT(same_as<decltype(views::zip(std::move(rngs)...)), ExpectedZipType>);
STATIC_ASSERT(noexcept(views::zip(std::move(rngs)...)) == is_noexcept);
}

// ... with const rvalue argument
Expand All @@ -291,12 +291,12 @@ constexpr bool test_one(TestContainerType& test_container, RangeTypes&&... range
using ExpectedZipType = ranges::zip_view<AllView<const remove_reference_t<RangeTypes>>...>;
constexpr bool is_noexcept = (is_nothrow_copy_constructible_v<AllView<RangeTypes>> && ...);

STATIC_ASSERT(same_as<decltype(views::zip(std::move(as_const(ranges))...)), ExpectedZipType>);
STATIC_ASSERT(noexcept(views::zip(std::move(as_const(ranges))...)) == is_noexcept);
STATIC_ASSERT(same_as<decltype(views::zip(std::move(as_const(rngs))...)), ExpectedZipType>);
STATIC_ASSERT(noexcept(views::zip(std::move(as_const(rngs))...)) == is_noexcept);
}

// Validate deduction guide
same_as<ZipType> auto zipped_range = ranges::zip_view{std::forward<RangeTypes>(ranges)...};
same_as<ZipType> auto zipped_range = ranges::zip_view{std::forward<RangeTypes>(rngs)...};
const auto tuple_element_arr = test_container.get_element_tuple_arr();
const auto const_tuple_element_arr = as_const(test_container).get_element_tuple_arr();

Expand Down