1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2024-12-31 18:15:01 +00:00
OpenMW/components/testing/expecterror.hpp
elsid 1e98cc6c3b
Move EXPECT_ERROR macro to a separate header
To include it only where it's required.
2024-06-10 23:12:15 +02:00

21 lines
1.2 KiB
C++

#ifndef OPENMW_COMPONENTS_TESTING_EXPECTERROR_H
#define OPENMW_COMPONENTS_TESTING_EXPECTERROR_H
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <exception>
#define EXPECT_ERROR(X, ERR_SUBSTR) \
try \
{ \
X; \
FAIL() << "Expected error"; \
} \
catch (const std::exception& e) \
{ \
EXPECT_THAT(e.what(), ::testing::HasSubstr(ERR_SUBSTR)); \
}
#endif