Skip to content

Commit

Permalink
Move MSVC workarounds from test/Jamfile to to_array_rvalue_test.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
pdimov committed Oct 4, 2024
1 parent d2d5cbe commit c18e5f2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
4 changes: 1 addition & 3 deletions test/Jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,5 @@ run function_ref_fn_noexcept_test.cpp ;
run function_ref_mfn_noexcept_test.cpp ;
run function_ref_obj_noexcept_test.cpp ;

# MSVC 14.0/14.1 C array rvalue references do not work
run to_array_lvalue_test.cpp ;
run to_array_rvalue_test.cpp : : :
<toolset>msvc-14.0:<build>no <toolset>msvc-14.1:<build>no ;
run to_array_rvalue_test.cpp ;
17 changes: 17 additions & 0 deletions test/to_array_rvalue_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,22 @@

#include <boost/compat/to_array.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/config.hpp>
#include <boost/config/workaround.hpp>
#include <boost/config/pragma_message.hpp>

#include <array>
#include <memory>
#include <utility>
#include <vector>

#if defined(BOOST_MSVC) && BOOST_MSVC < 1910

BOOST_PRAGMA_MESSAGE( "Test skipped because BOOST_MSVC < 1910" )
int main() {}

#else

namespace compat = boost::compat;

int main()
Expand Down Expand Up @@ -37,7 +47,9 @@ int main()
auto output = compat::to_array(std::move(input));
static_assert(std::is_same<decltype(output), std::array<std::vector<int>, 1>>::value, "");
BOOST_TEST_ALL_EQ(output[0].begin(), output[0].end(), vec.begin(), vec.end());
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1920)
BOOST_TEST(input[0].empty()); // input left in a moved-from state
#endif
}
{
// const values work (although they don't result in an effective move)
Expand All @@ -48,6 +60,7 @@ int main()
BOOST_TEST_ALL_EQ(output[0].begin(), output[0].end(), vec.begin(), vec.end());
BOOST_TEST_ALL_EQ(input[0].begin(), input[0].end(), vec.begin(), vec.end()); // input not modified
}
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1920)
{
// move-only types work
std::unique_ptr<int> input[] = {std::unique_ptr<int>{new int(42)}};
Expand All @@ -57,6 +70,8 @@ int main()
BOOST_TEST_EQ(output[0].get(), ptr);
BOOST_TEST_EQ(input[0].get(), nullptr); // input left in a moved-from state
}
#endif

{
// constexpr check
constexpr int input[] = {1, 2, 3};
Expand All @@ -69,3 +84,5 @@ int main()

return boost::report_errors();
}

#endif

0 comments on commit c18e5f2

Please sign in to comment.