diff --git a/format.h b/format.h index 9440bcbe..b4aee4c6 100644 --- a/format.h +++ b/format.h @@ -153,11 +153,13 @@ inline uint32_t clzll(uint64_t x) { #endif // Define FMT_USE_NOEXCEPT to make C++ Format use noexcept (C++11 feature). -#if FMT_USE_NOEXCEPT || FMT_HAS_FEATURE(cxx_noexcept) || \ - (FMT_GCC_VERSION >= 408 && FMT_HAS_GXX_CXX11) -# define FMT_NOEXCEPT noexcept -#else -# define FMT_NOEXCEPT throw() +#ifndef FMT_NOEXCEPT +# if FMT_USE_NOEXCEPT || FMT_HAS_FEATURE(cxx_noexcept) || \ + (FMT_GCC_VERSION >= 408 && FMT_HAS_GXX_CXX11) +# define FMT_NOEXCEPT noexcept +# else +# define FMT_NOEXCEPT throw() +# endif #endif // A macro to disallow the copy constructor and operator= functions diff --git a/test/format-impl-test.cc b/test/format-impl-test.cc index d4a03c4c..b6211f8f 100644 --- a/test/format-impl-test.cc +++ b/test/format-impl-test.cc @@ -25,6 +25,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#define FMT_NOEXCEPT #include "test-assert.h" // Include format.cc instead of format.h to test implementation-specific stuff. diff --git a/test/test-assert.h b/test/test-assert.h index 549cde3b..281b2367 100644 --- a/test/test-assert.h +++ b/test/test-assert.h @@ -28,15 +28,20 @@ #ifndef FMT_TEST_ASSERT_H #define FMT_TEST_ASSERT_H -#include +#include -static std::string last_assert; +class AssertionFailure : public std::logic_error { + public: + explicit AssertionFailure(const char *message) : std::logic_error(message) {} +}; #define FMT_ASSERT(condition, message) \ - if (!(condition)) last_assert = message; + if (!(condition)) throw AssertionFailure(message); + +#include "gtest-extra.h" // Expects an assertion failure. #define EXPECT_ASSERT(stmt, message) \ - { last_assert = ""; stmt; EXPECT_EQ(last_assert, message); } + EXPECT_THROW_MSG(stmt, AssertionFailure, message) #endif // FMT_TEST_ASSERT_H