diff --git a/test/Jamfile b/test/Jamfile index e1bacb5..06f5ae8 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -31,6 +31,7 @@ DEPENDS all : test ; [ run ../lexical_cast_test.cpp ../../test/build/boost_unit_test_framework ] [ run lexical_cast_loopback_test.cpp ../../test/build/boost_unit_test_framework ] [ run lexical_cast_abstract_test.cpp ../../test/build/boost_unit_test_framework ] + [ run lexical_cast_noncopyable_test.cpp ../../test/build/boost_unit_test_framework ] ; } diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 7108858..af68510 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -23,6 +23,7 @@ test-suite conversion [ run ../lexical_cast_test.cpp ../../test/build//boost_unit_test_framework/static ] [ run lexical_cast_loopback_test.cpp ../../test/build//boost_unit_test_framework/static ] [ run lexical_cast_abstract_test.cpp ../../test/build//boost_unit_test_framework/static ] + [ run lexical_cast_noncopyable_test.cpp ../../test/build//boost_unit_test_framework/static ] ; diff --git a/test/lexical_cast_noncopyable_test.cpp b/test/lexical_cast_noncopyable_test.cpp new file mode 100644 index 0000000..6284b14 --- /dev/null +++ b/test/lexical_cast_noncopyable_test.cpp @@ -0,0 +1,54 @@ +// Unit test for boost::lexical_cast. +// +// See http://www.boost.org for most recent version, including documentation. +// +// Copyright Alexander Nasonov, 2007. +// +// 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). +// +// Test that Source can be non-copyable. + +#include + +#if defined(__INTEL_COMPILER) +#pragma warning(disable: 193 383 488 981 1418 1419) +#elif defined(BOOST_MSVC) +#pragma warning(disable: 4097 4100 4121 4127 4146 4244 4245 4511 4512 4701 4800) +#endif + +#include +#include +#include + +using namespace boost; + +void test_noncopyable(); + +unit_test::test_suite *init_unit_test_suite(int, char *[]) +{ + unit_test_framework::test_suite *suite = + BOOST_TEST_SUITE("lexical_cast unit test"); + suite->add(BOOST_TEST_CASE(&test_noncopyable)); + + return suite; +} + +class Noncopyable : private boost::noncopyable +{ +public: + Noncopyable() {} +}; + +inline std::ostream &operator<<(std::ostream &out, const Noncopyable&) +{ + return out << "Noncopyable"; +} + +void test_noncopyable() +{ + Noncopyable x; + BOOST_CHECK(boost::lexical_cast(x) == "Noncopyable"); +} +