diff --git a/test/Jamfile b/test/Jamfile index 80ecab9..63e46cf 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -26,6 +26,7 @@ DEPENDS all : smart_ptr ; [ 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 ] ; diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 688cb2e..d4d7545 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -20,6 +20,7 @@ import testing ; [ run shared_from_this_test.cpp : : : gcc:-Wno-non-virtual-dtor ] [ run get_deleter_test.cpp ] [ run intrusive_ptr_test.cpp ] + [ run atomic_count_test.cpp ] [ compile-fail shared_ptr_assign_fail.cpp ] ; diff --git a/test/atomic_count_test.cpp b/test/atomic_count_test.cpp new file mode 100644 index 0000000..07e2e99 --- /dev/null +++ b/test/atomic_count_test.cpp @@ -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 +#include + +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(); +}