Skip to content

Commit

Permalink
Added a test for unallocated_resource with INVALID_HANDLE_VALUE on Wi…
Browse files Browse the repository at this point in the history
…ndows.
  • Loading branch information
Lastique committed Mar 12, 2024
1 parent d18cc5f commit 1a1dcd8
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions test/compile/unallocated_resource_win_invalid_handle_value.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* https://www.boost.org/LICENSE_1_0.txt)
*
* Copyright (c) 2024 Andrey Semashev
*/
/*!
* \file unallocated_resource_win_invalid_handle_value.cpp
* \author Andrey Semashev
*
* \brief This file tests that \c unallocated_resource supports
* \c INVALID_HANDLE_VALUE on Windows, as is described in the docs.
*
* This code relies on MSVC-specific behavior, which allows* \c INVALID_HANDLE_VALUE
* to be specified in non-type template parameters.
*/

#include <boost/config.hpp>

#if defined(BOOST_WINDOWS) && defined(BOOST_MSVC) && \
!defined(BOOST_NO_CXX17_FOLD_EXPRESSIONS) && !defined(BOOST_NO_CXX17_AUTO_NONTYPE_TEMPLATE_PARAMS)

#include <cstddef>
#include <windows.h>
#include <boost/core/functor.hpp>
#include <boost/scope/unique_resource.hpp>

int main()
{
boost::scope::unique_resource<
HANDLE,
boost::core::functor< CloseHandle >,
boost::scope::unallocated_resource< INVALID_HANDLE_VALUE, (HANDLE)NULL >
> ur;
(void)ur;

return 0;
}

#else // defined(BOOST_WINDOWS) ...

#include <boost/config/pragma_message.hpp>

BOOST_PRAGMA_MESSAGE("Skipping test because it is not supported on the platform/compiler/C++ version.")

int main()
{
}

#endif // defined(BOOST_WINDOWS) ...

0 comments on commit 1a1dcd8

Please sign in to comment.