mirror of
https://github.com/boostorg/detail.git
synced 2025-07-30 20:37:14 +02:00
Converted allocator_utilities_test to lightweight_test.hpp
This commit is contained in:
@ -5,14 +5,17 @@
|
|||||||
|
|
||||||
#include <boost/detail/allocator_utilities.hpp>
|
#include <boost/detail/allocator_utilities.hpp>
|
||||||
#include <boost/static_assert.hpp>
|
#include <boost/static_assert.hpp>
|
||||||
#include <cassert>
|
#include <boost/core/lightweight_test.hpp>
|
||||||
|
#include <boost/type_traits/is_same.hpp>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
typedef std::allocator<int> std_int_allocator;
|
typedef std::allocator<int> std_int_allocator;
|
||||||
typedef boost::detail::allocator::rebind_to<std_int_allocator, char>::type char_allocator;
|
typedef boost::detail::allocator::rebind_to<std_int_allocator, char>::type char_allocator;
|
||||||
typedef boost::detail::allocator::rebind_to<char_allocator, int>::type int_allocator;
|
typedef boost::detail::allocator::rebind_to<char_allocator, int>::type int_allocator;
|
||||||
typedef boost::detail::allocator::rebind_to<int_allocator, char>::type char_allocator2;
|
typedef boost::detail::allocator::rebind_to<int_allocator, char>::type char_allocator2;
|
||||||
|
|
||||||
int main() {
|
int main()
|
||||||
|
{
|
||||||
BOOST_STATIC_ASSERT((!boost::is_same<char_allocator, int_allocator>::value));
|
BOOST_STATIC_ASSERT((!boost::is_same<char_allocator, int_allocator>::value));
|
||||||
BOOST_STATIC_ASSERT((boost::is_same<char_allocator, char_allocator2>::value));
|
BOOST_STATIC_ASSERT((boost::is_same<char_allocator, char_allocator2>::value));
|
||||||
|
|
||||||
@ -25,7 +28,7 @@ int main() {
|
|||||||
// Check allocate works okay
|
// Check allocate works okay
|
||||||
{
|
{
|
||||||
char_allocator::pointer p = a2.allocate(10);
|
char_allocator::pointer p = a2.allocate(10);
|
||||||
assert(p);
|
BOOST_TEST(!!p);
|
||||||
a2.deallocate(p, 10);
|
a2.deallocate(p, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,8 +36,10 @@ int main() {
|
|||||||
{
|
{
|
||||||
int_allocator::pointer p2 = a3.allocate(1);
|
int_allocator::pointer p2 = a3.allocate(1);
|
||||||
boost::detail::allocator::construct(p2, 25);
|
boost::detail::allocator::construct(p2, 25);
|
||||||
assert(*p2 == 25);
|
BOOST_TEST(*p2 == 25);
|
||||||
boost::detail::allocator::destroy(p2);
|
boost::detail::allocator::destroy(p2);
|
||||||
a3.deallocate(p2, 1);
|
a3.deallocate(p2, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user