comparison dep/fmt/test/assert-test.cc @ 343:1faa72660932

*: transfer back to cmake from autotools autotools just made lots of things more complicated than they should have and many things broke (i.e. translations)
author Paper <paper@paper.us.eu.org>
date Thu, 20 Jun 2024 05:56:06 -0400
parents
children
comparison
equal deleted inserted replaced
342:adb79bdde329 343:1faa72660932
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/gtest.h"
14
15 TEST(assert_test, 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 TEST(assert_test, dangling_else) {
24 bool test_condition = false;
25 bool executed_else = false;
26 if (test_condition)
27 FMT_ASSERT(true, "");
28 else
29 executed_else = true;
30 EXPECT_TRUE(executed_else);
31 }