2020-10-11 18:24:17 +03: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 20:16:51 +03:00
|
|
|
//
|
|
|
|
// Copyright (c) 2012 - present, Victor Zverovich
|
|
|
|
// All rights reserved.
|
|
|
|
//
|
|
|
|
// For the license information refer to format.h.
|
2015-06-22 18:17:23 +03:00
|
|
|
|
2017-12-06 18:42:42 +03:00
|
|
|
#include "fmt/core.h"
|
2021-04-29 01:59:43 +03:00
|
|
|
#include "gtest/gtest.h"
|
2015-06-22 18:17:23 +03:00
|
|
|
|
2021-04-26 07:26:30 +03:00
|
|
|
TEST(assert_test, fail) {
|
2015-06-22 18:17:23 +03:00
|
|
|
#if GTEST_HAS_DEATH_TEST
|
2020-02-24 22:32:34 +03:00
|
|
|
EXPECT_DEBUG_DEATH(FMT_ASSERT(false, "don't panic!"), "don't panic!");
|
2015-06-22 18:17:23 +03:00
|
|
|
#else
|
2020-02-24 22:32:34 +03:00
|
|
|
fmt::print("warning: death tests are not supported\n");
|
2015-06-22 18:17:23 +03:00
|
|
|
#endif
|
|
|
|
}
|
2019-11-30 18:52:33 +03:00
|
|
|
|
2021-04-26 07:26:30 +03:00
|
|
|
TEST(assert_test, dangling_else) {
|
|
|
|
bool test_condition = false;
|
2019-11-30 18:52:33 +03:00
|
|
|
bool executed_else = false;
|
|
|
|
if (test_condition)
|
|
|
|
FMT_ASSERT(true, "");
|
|
|
|
else
|
|
|
|
executed_else = true;
|
|
|
|
EXPECT_TRUE(executed_else);
|
|
|
|
}
|