1 // Formatting library for C++ - assertion tests
2 //
3 // Copyright (c) 2012 - present, Victor Zverovich
4 // All rights reserved.
5 //
6 // For the license information refer to format.h.
7 
8 #include "fmt/core.h"
9 #include "gtest.h"
10 
TEST(AssertTest,Fail)11 TEST(AssertTest, Fail) {
12 #if GTEST_HAS_DEATH_TEST
13   EXPECT_DEBUG_DEATH(FMT_ASSERT(false, "don't panic!"), "don't panic!");
14 #else
15   fmt::print("warning: death tests are not supported\n");
16 #endif
17 }
18 
19 bool test_condition = false;
20 
TEST(AssertTest,DanglingElse)21 TEST(AssertTest, DanglingElse) {
22   bool executed_else = false;
23   if (test_condition)
24     FMT_ASSERT(true, "");
25   else
26     executed_else = true;
27   EXPECT_TRUE(executed_else);
28 }
29