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:
parent
7d1cd11ba9
commit
1e98cc6c3b
@ -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>
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
|
@ -2,6 +2,7 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <components/lua/luastate.hpp>
|
||||
#include <components/testing/expecterror.hpp>
|
||||
#include <components/testing/util.hpp>
|
||||
|
||||
namespace
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -513,6 +513,7 @@ else ()
|
||||
endif()
|
||||
|
||||
add_component_dir(testing
|
||||
expecterror
|
||||
util
|
||||
)
|
||||
|
||||
|
20
components/testing/expecterror.hpp
Normal file
20
components/testing/expecterror.hpp
Normal 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
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user