userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
death_tests.hpp
Go to the documentation of this file.
1
#pragma once
2
6
7
#include <gtest/gtest.h>
8
9
#include <
userver/utils/assert.hpp
>
10
#include <userver/utils/impl/disable_core_dumps.hpp>
11
12
USERVER_NAMESPACE_BEGIN
13
14
namespace
utest::impl {
15
16
class
DeathTestScope final {
17
public
:
18
DeathTestScope() { utils::impl::dump_stacktrace_on_assert_failure =
false
; }
19
~DeathTestScope() { utils::impl::dump_stacktrace_on_assert_failure =
true
; }
20
21
bool
ShouldKeepIterating() const noexcept {
return
keep_iterating_; }
22
void
StopIterating() noexcept { keep_iterating_ =
false
; }
23
24
private
:
25
utils::impl::DisableCoreDumps disable_core_dumps_;
26
bool
keep_iterating_{
true
};
27
};
28
29
}
// namespace utest::impl
30
31
USERVER_NAMESPACE_END
32
38
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
39
#define UEXPECT_DEATH(statement, regex_or_matcher) \
40
for (USERVER_NAMESPACE::utest::impl::DeathTestScope utest_impl_death_test_scope; \
41
utest_impl_death_test_scope.ShouldKeepIterating(); \
42
utest_impl_death_test_scope.StopIterating()) \
43
EXPECT_DEATH(statement, regex_or_matcher)
44
50
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
51
#define UEXPECT_DEBUG_DEATH(statement, regex_or_matcher) \
52
for (USERVER_NAMESPACE::utest::impl::DeathTestScope utest_impl_death_test_scope; \
53
utest_impl_death_test_scope.ShouldKeepIterating(); \
54
utest_impl_death_test_scope.StopIterating()) \
55
EXPECT_DEBUG_DEATH(statement, regex_or_matcher)
userver
utest
death_tests.hpp
Generated on
for userver by
Doxygen
1.17.0