Helper for the [EXPECT,ASSERT]_[MOOSEERROR,THROW]_[MSG,MSG_CONTAINS] macros.
70{
71 static_assert(std::is_base_of_v<std::exception, ExceptionType>, "Not an exception");
72
73 std::ostringstream error;
74
75 try
76 {
77 std::unique_ptr<Moose::ScopedThrowOnError> scoped_throw_on_error;
78 if constexpr (set_throw_on_error)
79 scoped_throw_on_error = std::make_unique<Moose::ScopedThrowOnError>();
80
81 fn();
82
83 error <<
"Expected exception of type " <<
libMesh::demangle(
typeid(ExceptionType).name())
84 << " but no exception was thrown.";
85 }
86 catch (const ExceptionType & ex)
87 {
88
89 if constexpr (exact)
90 {
91 if (std::string(ex.what()) == message)
92 return;
93 }
94
95 else
96 {
97 if (std::string(ex.what()).find(message) != std::string::npos)
98 return;
99 }
100
101 error << "Expected" << (exact ? "" : " partial") << " exception message: \"" << message
102 << "\"\n Actual exception message: \"" << ex.what() << "\"";
103 }
104 catch (const std::exception & ex)
105 {
108 }
109
110 ::testing::internal::AssertHelper(
111 ::testing::TestPartResult::kNonFatalFailure, file, line, error.str().c_str()) =
112 ::testing::Message();
113}
std::string name(const ElemQuality q)
std::string demangle(const char *name)