]> git.proxmox.com Git - ceph.git/blame - ceph/src/fmt/test/assert-test.cc
import quincy beta 17.1.0
[ceph.git] / ceph / src / fmt / test / assert-test.cc
CommitLineData
20effc67
TL
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.
11fdf7f2
TL
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"
20effc67 13#include "gtest/gtest.h"
11fdf7f2 14
20effc67 15TEST(assert_test, fail) {
11fdf7f2 16#if GTEST_HAS_DEATH_TEST
f67539c2 17 EXPECT_DEBUG_DEATH(FMT_ASSERT(false, "don't panic!"), "don't panic!");
11fdf7f2 18#else
f67539c2 19 fmt::print("warning: death tests are not supported\n");
11fdf7f2 20#endif
f67539c2 21}
11fdf7f2 22
20effc67
TL
23TEST(assert_test, dangling_else) {
24 bool test_condition = false;
f67539c2
TL
25 bool executed_else = false;
26 if (test_condition)
27 FMT_ASSERT(true, "");
28 else
29 executed_else = true;
30 EXPECT_TRUE(executed_else);
11fdf7f2 31}