]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/format/test/format_test_enum.cpp
1 // ------------------------------------------------------------------------------
2 // format_test_enum.cpp : test format use with enums
3 // ------------------------------------------------------------------------------
5 // Copyright Steven Watanabe 2009.
7 // Distributed under the Boost Software License, Version 1.0. (See
8 // accompanying file LICENSE_1_0.txt or copy at
9 // http://www.boost.org/LICENSE_1_0.txt)
11 // See http://www.boost.org/libs/format for library home page
13 // ------------------------------------------------------------------------------
15 #include "boost/format.hpp"
17 #define BOOST_INCLUDE_MAIN
18 #include <boost/test/test_tools.hpp>
20 enum enum_plain
{ PLAIN
};
22 enum enum_overloaded
{ OVERLOADED
};
23 typedef enum { OVERLOADED_TYPEDEF
} enum_overloaded_typedef
;
25 std::ostream
& operator<<(std::ostream
& os
, enum_overloaded
) {
30 std::ostream
& operator<<(std::ostream
& os
, enum_overloaded_typedef
) {
35 int test_main(int, char*[]) {
36 // in this case, we should implicitly convert to int
37 BOOST_CHECK_EQUAL((boost::format("%d") % PLAIN
).str(), "0");
38 BOOST_CHECK_EQUAL((boost::format("%d") % ANONYMOUS
).str(), "0");
40 // but here we need to use the overloaded operator
41 BOOST_CHECK_EQUAL((boost::format("%s") % OVERLOADED
).str(), "overloaded");
42 BOOST_CHECK_EQUAL((boost::format("%s") % OVERLOADED_TYPEDEF
).str(), "overloaded");