2018-03-04 17:16:51 +00:00
|
|
|
// Formatting library for C++ - assertion tests
|
|
|
|
//
|
|
|
|
// Copyright (c) 2012 - present, Victor Zverovich
|
|
|
|
// All rights reserved.
|
|
|
|
//
|
|
|
|
// For the license information refer to format.h.
|
2015-06-22 15:17:23 +00:00
|
|
|
|
2017-12-06 15:42:42 +00:00
|
|
|
#include "fmt/core.h"
|
2018-06-06 13:57:59 +00:00
|
|
|
#include "gtest.h"
|
2015-06-22 15:17:23 +00:00
|
|
|
|
2020-02-24 19:32:34 +00:00
|
|
|
TEST(AssertTest, Fail) {
|
2015-06-22 15:17:23 +00:00
|
|
|
#if GTEST_HAS_DEATH_TEST
|
2020-02-24 19:32:34 +00:00
|
|
|
EXPECT_DEBUG_DEATH(FMT_ASSERT(false, "don't panic!"), "don't panic!");
|
2015-06-22 15:17:23 +00:00
|
|
|
#else
|
2020-02-24 19:32:34 +00:00
|
|
|
fmt::print("warning: death tests are not supported\n");
|
2015-06-22 15:17:23 +00:00
|
|
|
#endif
|
|
|
|
}
|
2019-11-30 15:52:33 +00:00
|
|
|
|
|
|
|
bool test_condition = false;
|
|
|
|
|
|
|
|
TEST(AssertTest, DanglingElse) {
|
|
|
|
bool executed_else = false;
|
|
|
|
if (test_condition)
|
|
|
|
FMT_ASSERT(true, "");
|
|
|
|
else
|
|
|
|
executed_else = true;
|
|
|
|
EXPECT_TRUE(executed_else);
|
|
|
|
}
|