mirror of
https://github.com/fmtlib/fmt.git
synced 2024-11-10 05:10:05 +00:00
Fix assertion tests
This commit is contained in:
parent
8ab665afbc
commit
abcc2d96f0
2
format.h
2
format.h
@ -153,12 +153,14 @@ inline uint32_t clzll(uint64_t x) {
|
||||
#endif
|
||||
|
||||
// Define FMT_USE_NOEXCEPT to make C++ Format use noexcept (C++11 feature).
|
||||
#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
|
||||
// This should be used in the private: declarations for a class
|
||||
|
@ -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.
|
||||
|
@ -28,15 +28,20 @@
|
||||
#ifndef FMT_TEST_ASSERT_H
|
||||
#define FMT_TEST_ASSERT_H
|
||||
|
||||
#include <string>
|
||||
#include <stdexcept>
|
||||
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user