1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2024-12-29 03:19:44 +00:00

Move EXPECT_ERROR macro to a separate header

To include it only where it's required.
This commit is contained in:
elsid 2024-06-09 14:55:08 +02:00
parent 7d1cd11ba9
commit 1e98cc6c3b
No known key found for this signature in database
GPG Key ID: 4DE04C198CBA7625
9 changed files with 28 additions and 16 deletions

View File

@ -1,7 +1,7 @@
#include <components/esm/refid.hpp>
#include <components/esm3/esmreader.hpp>
#include <components/esm3/esmwriter.hpp>
#include <components/testing/util.hpp>
#include <components/testing/expecterror.hpp>
#include <gmock/gmock.h>
#include <gtest/gtest.h>

View File

@ -3,12 +3,11 @@
#include <components/lua/asyncpackage.hpp>
#include <components/lua/luastate.hpp>
#include <components/testing/util.hpp>
#include <components/testing/expecterror.hpp>
namespace
{
using namespace testing;
using namespace TestingOpenMW;
struct LuaCoroutineCallbackTest : Test
{

View File

@ -9,6 +9,7 @@
#include <components/esm3/readerscache.hpp>
#include <components/lua/configuration.hpp>
#include <components/lua/serialization.hpp>
#include <components/testing/expecterror.hpp>
#include <components/testing/util.hpp>
namespace

View File

@ -2,6 +2,7 @@
#include <gtest/gtest.h>
#include <components/lua/luastate.hpp>
#include <components/testing/expecterror.hpp>
#include <components/testing/util.hpp>
namespace

View File

@ -13,7 +13,7 @@
#include <components/misc/color.hpp>
#include <components/misc/endianness.hpp>
#include <components/testing/util.hpp>
#include <components/testing/expecterror.hpp>
namespace
{

View File

@ -3,7 +3,7 @@
#include <components/lua/luastate.hpp>
#include <components/lua/utilpackage.hpp>
#include <components/testing/util.hpp>
#include <components/testing/expecterror.hpp>
namespace
{

View File

@ -513,6 +513,7 @@ else ()
endif()
add_component_dir(testing
expecterror
util
)

View File

@ -0,0 +1,20 @@
#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

View File

@ -3,6 +3,7 @@
#include <filesystem>
#include <initializer_list>
#include <memory>
#include <sstream>
#include <components/misc/strings/conversion.hpp>
@ -80,15 +81,4 @@ namespace TestingOpenMW
}
}
#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