Files

32 lines
875 B
C++
Raw Permalink Normal View History

2020-10-11 08:24:17 -07:00
// Formatting library for C++ - FMT_ASSERT test
//
// It is a separate test to minimize the number of EXPECT_DEBUG_DEATH checks
// which are slow on some platforms. In other tests FMT_ASSERT is made to throw
// an exception which is much faster and easier to check.
2018-03-04 09:16:51 -08:00
//
2026-05-31 08:54:06 -07:00
// Copyright (c) 2012 - present, Victor Zverovich and {fmt} contributors
2018-03-04 09:16:51 -08:00
// All rights reserved.
//
// For the license information refer to format.h.
2015-06-22 08:17:23 -07:00
2024-01-09 19:30:46 -08:00
#include "fmt/base.h"
#include "gtest/gtest.h"
2015-06-22 08:17:23 -07:00
2021-04-25 21:26:30 -07:00
TEST(assert_test, fail) {
2020-02-24 11:32:34 -08:00
#if GTEST_HAS_DEATH_TEST
EXPECT_DEBUG_DEATH(FMT_ASSERT(false, "don't panic!"), "don't panic!");
#else
fmt::print("warning: death tests are not supported\n");
#endif
2015-06-22 08:17:23 -07:00
}
2019-11-30 07:52:33 -08:00
2021-04-25 21:26:30 -07:00
TEST(assert_test, dangling_else) {
bool test_condition = false;
2019-11-30 07:52:33 -08:00
bool executed_else = false;
if (test_condition)
FMT_ASSERT(true, "");
else
executed_else = true;
EXPECT_TRUE(executed_else);
}