|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r57695 - trunk/libs/format/test
From: Samuel.Krempp_at_[hidden]
Date: 2009-11-15 18:10:55
Author: samuel_krempp
Date: 2009-11-15 18:10:54 EST (Sun, 15 Nov 2009)
New Revision: 57695
URL: http://svn.boost.org/trac/boost/changeset/57695
Log:
test support for enums on gcc (patch by Steven Watanabe)
fixes Ticket #2015
Added:
trunk/libs/format/test/format_test_enum.cpp (contents, props changed)
Text files modified:
trunk/libs/format/test/Jamfile.v2 | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
Modified: trunk/libs/format/test/Jamfile.v2
==============================================================================
--- trunk/libs/format/test/Jamfile.v2 (original)
+++ trunk/libs/format/test/Jamfile.v2 2009-11-15 18:10:54 EST (Sun, 15 Nov 2009)
@@ -18,6 +18,7 @@
[ run format_test2.cpp ]
[ run format_test3.cpp ]
[ run format_test_wstring.cpp ]
+ [ run format_test_enum.cpp ]
;
}
Added: trunk/libs/format/test/format_test_enum.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/format/test/format_test_enum.cpp 2009-11-15 18:10:54 EST (Sun, 15 Nov 2009)
@@ -0,0 +1,45 @@
+// ------------------------------------------------------------------------------
+// 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/format.hpp"
+
+#define BOOST_INCLUDE_MAIN
+#include <boost/test/test_tools.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 test_main(int, char*[]) {
+ // in this case, we should implicitly convert to int
+ BOOST_CHECK_EQUAL((boost::format("%d") % PLAIN).str(), "0");
+ BOOST_CHECK_EQUAL((boost::format("%d") % ANONYMOUS).str(), "0");
+
+ // but here we need to use the overloaded operator
+ BOOST_CHECK_EQUAL((boost::format("%s") % OVERLOADED).str(), "overloaded");
+ BOOST_CHECK_EQUAL((boost::format("%s") % OVERLOADED_TYPEDEF).str(), "overloaded");
+
+ return 0;
+}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk