format/test/format_test_enum.cpp
James E. King, III e4b101cd92 expand appveyor to cover cygwin 32-bit and 64-bit, mingw 32-bit
unit tests were failing on cygwin so I changed them to use lightweight test
therefore Boost.Format no longer depends on Boost.Test
2018-01-22 12:48:59 -05:00

44 lines
1.4 KiB
C++

// ------------------------------------------------------------------------------
// format_test_enum.cpp : test format use with enums
// ------------------------------------------------------------------------------
// Copyright Steven Watanabe 2009.
//
// 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)
// See http://www.boost.org/libs/format for library home page
// ------------------------------------------------------------------------------
#include <boost/detail/lightweight_test.hpp>
#include <boost/format.hpp>
enum enum_plain { PLAIN };
enum { ANONYMOUS };
enum enum_overloaded { OVERLOADED };
typedef enum { OVERLOADED_TYPEDEF } enum_overloaded_typedef;
std::ostream& operator<<(std::ostream& os, enum_overloaded) {
os << "overloaded";
return(os);
}
std::ostream& operator<<(std::ostream& os, enum_overloaded_typedef) {
os << "overloaded";
return(os);
}
int main(int, char*[]) {
// in this case, we should implicitly convert to int
BOOST_TEST_EQ((boost::format("%d") % PLAIN).str(), "0");
BOOST_TEST_EQ((boost::format("%d") % ANONYMOUS).str(), "0");
// but here we need to use the overloaded operator
BOOST_TEST_EQ((boost::format("%s") % OVERLOADED).str(), "overloaded");
BOOST_TEST_EQ((boost::format("%s") % OVERLOADED_TYPEDEF).str(), "overloaded");
return boost::report_errors();
}