1 // Formatting library for C++ - FMT_ASSERT test
2 //
3 // It is a separate test to minimize the number of EXPECT_DEBUG_DEATH checks
4 // which are slow on some platforms. In other tests FMT_ASSERT is made to throw
5 // an exception which is much faster and easier to check.
6 //
7 // Copyright (c) 2012 - present, Victor Zverovich
8 // All rights reserved.
9 //
10 // For the license information refer to format.h.
11 
12 #include "fmt/core.h"
13 #include "gtest.h"
14 
TEST(AssertTest,Fail)15 TEST(AssertTest, Fail) {
16 #if GTEST_HAS_DEATH_TEST
17   EXPECT_DEBUG_DEATH(FMT_ASSERT(false, "don't panic!"), "don't panic!");
18 #else
19   fmt::print("warning: death tests are not supported\n");
20 #endif
21 }
22 
23 bool test_condition = false;
24 
TEST(AssertTest,DanglingElse)25 TEST(AssertTest, DanglingElse) {
26   bool executed_else = false;
27   if (test_condition)
28     FMT_ASSERT(true, "");
29   else
30     executed_else = true;
31   EXPECT_TRUE(executed_else);
32 }
33