forked from boostorg/smart_ptr
atomic_count_test.cpp added.
[SVN r27746]
This commit is contained in:
@ -26,6 +26,7 @@ DEPENDS all : smart_ptr ;
|
|||||||
[ run get_deleter_test.cpp ]
|
[ run get_deleter_test.cpp ]
|
||||||
[ run intrusive_ptr_test.cpp ]
|
[ run intrusive_ptr_test.cpp ]
|
||||||
[ run intrusive_ptr_test.cpp ]
|
[ run intrusive_ptr_test.cpp ]
|
||||||
|
[ run atomic_count_test.cpp ]
|
||||||
[ compile-fail shared_ptr_assign_fail.cpp ]
|
[ compile-fail shared_ptr_assign_fail.cpp ]
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ import testing ;
|
|||||||
[ run shared_from_this_test.cpp : : : <toolset>gcc:<cxxflags>-Wno-non-virtual-dtor ]
|
[ run shared_from_this_test.cpp : : : <toolset>gcc:<cxxflags>-Wno-non-virtual-dtor ]
|
||||||
[ run get_deleter_test.cpp ]
|
[ run get_deleter_test.cpp ]
|
||||||
[ run intrusive_ptr_test.cpp ]
|
[ run intrusive_ptr_test.cpp ]
|
||||||
|
[ run atomic_count_test.cpp ]
|
||||||
[ compile-fail shared_ptr_assign_fail.cpp ]
|
[ compile-fail shared_ptr_assign_fail.cpp ]
|
||||||
;
|
;
|
||||||
|
|
||||||
|
40
test/atomic_count_test.cpp
Normal file
40
test/atomic_count_test.cpp
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
//
|
||||||
|
// astomic_count_test.cpp
|
||||||
|
//
|
||||||
|
// Copyright 2005 Peter Dimov
|
||||||
|
//
|
||||||
|
// Distributed under the Boost Software License, Version 1.0. (See
|
||||||
|
// accompanying file LICENSE_1_0.txt or copy at
|
||||||
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <boost/detail/atomic_count.hpp>
|
||||||
|
#include <boost/detail/lightweight_test.hpp>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
boost::detail::atomic_count n( 4 );
|
||||||
|
|
||||||
|
BOOST_TEST( n == 4L );
|
||||||
|
|
||||||
|
++n;
|
||||||
|
|
||||||
|
BOOST_TEST( n == 5L );
|
||||||
|
BOOST_TEST( --n != 0L );
|
||||||
|
|
||||||
|
boost::detail::atomic_count m( 0 );
|
||||||
|
|
||||||
|
BOOST_TEST( m == 0 );
|
||||||
|
|
||||||
|
++m;
|
||||||
|
|
||||||
|
BOOST_TEST( m == 1 );
|
||||||
|
|
||||||
|
++m;
|
||||||
|
|
||||||
|
BOOST_TEST( m == 2 );
|
||||||
|
BOOST_TEST( --m != 0 );
|
||||||
|
BOOST_TEST( --m == 0 );
|
||||||
|
|
||||||
|
return boost::report_errors();
|
||||||
|
}
|
Reference in New Issue
Block a user