Include fmt 11.0.2
[openal-soft.git] / fmt-11.0.2 / test / test-assert.h
blobab7b2bf732f1901ab314874471e84879c217c4c1
1 // Formatting library for C++ - test version of FMT_ASSERT
2 //
3 // Copyright (c) 2012 - present, Victor Zverovich
4 // All rights reserved.
5 //
6 // For the license information refer to format.h.
8 #ifndef FMT_TEST_ASSERT_H_
9 #define FMT_TEST_ASSERT_H_
11 #include <stdexcept>
13 void throw_assertion_failure(const char* message);
14 #define FMT_ASSERT(condition, message) \
15 if (!(condition)) throw_assertion_failure(message);
17 #include "gtest/gtest.h"
19 class assertion_failure : public std::logic_error {
20 public:
21 explicit assertion_failure(const char* message) : std::logic_error(message) {}
23 private:
24 virtual void avoid_weak_vtable();
27 void assertion_failure::avoid_weak_vtable() {}
29 // We use a separate function (rather than throw directly from FMT_ASSERT) to
30 // avoid GCC's -Wterminate warning when FMT_ASSERT is used in a destructor.
31 inline void throw_assertion_failure(const char* message) {
32 throw assertion_failure(message);
35 // Expects an assertion failure.
36 #define EXPECT_ASSERT(stmt, message) \
37 FMT_TEST_THROW_(stmt, assertion_failure, message, GTEST_NONFATAL_FAILURE_)
39 #endif // FMT_TEST_ASSERT_H_