Imported Upstream version 1.51.0
[platform/upstream/boost.git] / libs / lexical_cast / test / lexical_cast_noncopyable_test.cpp
1 //  Unit test for boost::lexical_cast.
2 //
3 //  See http://www.boost.org for most recent version, including documentation.
4 //
5 //  Copyright Alexander Nasonov, 2007.
6 //
7 //  Distributed under the Boost
8 //  Software License, Version 1.0. (See accompanying file
9 //  LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt).
10 //
11 //  Test that Source can be non-copyable.
12
13 #include <boost/config.hpp>
14
15 #if defined(__INTEL_COMPILER)
16 #pragma warning(disable: 193 383 488 981 1418 1419)
17 #elif defined(BOOST_MSVC)
18 #pragma warning(disable: 4097 4100 4121 4127 4146 4244 4245 4511 4512 4701 4800)
19 #endif
20
21 #include <boost/lexical_cast.hpp>
22 #include <boost/noncopyable.hpp>
23 #include <boost/test/unit_test.hpp>
24
25 using namespace boost;
26
27 void test_noncopyable();
28
29 unit_test::test_suite *init_unit_test_suite(int, char *[])
30 {
31     unit_test::test_suite *suite =
32         BOOST_TEST_SUITE("lexical_cast unit test");
33     suite->add(BOOST_TEST_CASE(&test_noncopyable));
34
35     return suite;
36 }
37
38 class Noncopyable : private boost::noncopyable
39 {
40 public:
41     Noncopyable() {}
42 };
43
44 inline std::ostream &operator<<(std::ostream &out, const Noncopyable&)
45 {
46     return out << "Noncopyable";
47 }
48
49 void test_noncopyable()
50 {
51     Noncopyable x;
52     BOOST_CHECK(boost::lexical_cast<std::string>(x) == "Noncopyable");
53 }
54