1 | // Unit test for boost::lexical_cast. |
---|---|
2 | // |
3 | // See http://www.boost.org for most recent version, including documentation. |
4 | // |
5 | // Copyright Sergey Shandar 2005, Alexander Nasonov, 2007. |
6 | // Copyright Antony Polukhin, 2023-2024. |
7 | // |
8 | // Distributed under the Boost |
9 | // Software License, Version 1.0. (See accompanying file |
10 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt). |
11 | // |
12 | // Test abstract class. Bug 1358600: |
13 | // http://sf.net/tracker/?func=detail&aid=1358600&group_id=7586&atid=107586 |
14 | |
15 | #include <boost/lexical_cast.hpp> |
16 | |
17 | #include <boost/core/lightweight_test.hpp> |
18 | |
19 | class A |
20 | { |
21 | public: |
22 | virtual void out(std::ostream &) const = 0; |
23 | virtual ~A() {} |
24 | }; |
25 | |
26 | class B: public A |
27 | { |
28 | public: |
29 | virtual void out(std::ostream &O) const { O << "B"; } |
30 | }; |
31 | |
32 | std::ostream &operator<<(std::ostream &O, const A &a) |
33 | { |
34 | a.out(O); |
35 | return O; |
36 | } |
37 | |
38 | void test_abstract() |
39 | { |
40 | const A &a = B(); |
41 | BOOST_TEST(boost::lexical_cast<std::string>(a) == "B"); |
42 | } |
43 | |
44 | int main() |
45 | { |
46 | test_abstract(); |
47 | return boost::report_errors(); |
48 | } |
49 | |
50 |