mirror of https://github.com/OpenMW/openmw.git
Merge branch 'unit_tests' into 'master'
Split openmw_test_suite into openmw and components tests See merge request OpenMW/openmw!4166pull/3236/head
commit
0a7f4e5149
@ -1,12 +1,11 @@
|
||||
#include "gmock/gmock.h"
|
||||
#include <gmock/gmock.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <components/files/configurationmanager.hpp>
|
||||
#include <components/fx/technique.hpp>
|
||||
#include <components/resource/imagemanager.hpp>
|
||||
#include <components/settings/settings.hpp>
|
||||
|
||||
#include "../testing_util.hpp"
|
||||
#include <components/testing/util.hpp>
|
||||
|
||||
namespace
|
||||
{
|
@ -1,15 +1,13 @@
|
||||
#include "gmock/gmock.h"
|
||||
#include <gmock/gmock.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <components/lua/asyncpackage.hpp>
|
||||
#include <components/lua/luastate.hpp>
|
||||
|
||||
#include "../testing_util.hpp"
|
||||
#include <components/testing/expecterror.hpp>
|
||||
|
||||
namespace
|
||||
{
|
||||
using namespace testing;
|
||||
using namespace TestingOpenMW;
|
||||
|
||||
struct LuaCoroutineCallbackTest : Test
|
||||
{
|
@ -1,10 +1,9 @@
|
||||
#include "gmock/gmock.h"
|
||||
#include <gmock/gmock.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <components/lua/inputactions.hpp>
|
||||
#include <components/lua/scriptscontainer.hpp>
|
||||
|
||||
#include "../testing_util.hpp"
|
||||
#include <components/testing/util.hpp>
|
||||
|
||||
namespace
|
||||
{
|
@ -1,13 +1,11 @@
|
||||
#include "gmock/gmock.h"
|
||||
#include <gmock/gmock.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <components/files/fixedpath.hpp>
|
||||
|
||||
#include <components/l10n/manager.hpp>
|
||||
#include <components/lua/l10n.hpp>
|
||||
#include <components/lua/luastate.hpp>
|
||||
|
||||
#include "../testing_util.hpp"
|
||||
#include <components/testing/util.hpp>
|
||||
|
||||
namespace
|
||||
{
|
@ -1,9 +1,9 @@
|
||||
#include "gmock/gmock.h"
|
||||
#include <gmock/gmock.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <components/lua/luastate.hpp>
|
||||
|
||||
#include "../testing_util.hpp"
|
||||
#include <components/testing/expecterror.hpp>
|
||||
#include <components/testing/util.hpp>
|
||||
|
||||
namespace
|
||||
{
|
@ -1,10 +1,9 @@
|
||||
#include "gmock/gmock.h"
|
||||
#include <gmock/gmock.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <components/lua/luastate.hpp>
|
||||
#include <components/lua/utilpackage.hpp>
|
||||
|
||||
#include "../testing_util.hpp"
|
||||
#include <components/testing/expecterror.hpp>
|
||||
|
||||
namespace
|
||||
{
|
@ -1,5 +1,6 @@
|
||||
#include "../testing_util.hpp"
|
||||
#include "components/misc/resourcehelpers.hpp"
|
||||
#include <components/misc/resourcehelpers.hpp>
|
||||
#include <components/testing/util.hpp>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
namespace
|
@ -1,11 +1,10 @@
|
||||
#include <components/settings/parser.hpp>
|
||||
#include <components/testing/util.hpp>
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "../testing_util.hpp"
|
||||
|
||||
namespace
|
||||
{
|
||||
using namespace testing;
|
@ -1,12 +1,11 @@
|
||||
#include <components/settings/shadermanager.hpp>
|
||||
#include <components/testing/util.hpp>
|
||||
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "../testing_util.hpp"
|
||||
|
||||
namespace
|
||||
{
|
||||
using namespace testing;
|
@ -1,12 +1,11 @@
|
||||
#include <components/files/conversion.hpp>
|
||||
#include <components/shader/shadermanager.hpp>
|
||||
#include <components/testing/util.hpp>
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "../testing_util.hpp"
|
||||
|
||||
namespace
|
||||
{
|
||||
using namespace testing;
|
@ -0,0 +1,58 @@
|
||||
include_directories(SYSTEM ${GTEST_INCLUDE_DIRS})
|
||||
include_directories(SYSTEM ${GMOCK_INCLUDE_DIRS})
|
||||
|
||||
file(GLOB UNITTEST_SRC_FILES
|
||||
main.cpp
|
||||
|
||||
options.cpp
|
||||
|
||||
mwworld/test_store.cpp
|
||||
mwworld/testduration.cpp
|
||||
mwworld/testtimestamp.cpp
|
||||
|
||||
mwdialogue/test_keywordsearch.cpp
|
||||
|
||||
mwscript/test_scripts.cpp
|
||||
)
|
||||
|
||||
source_group(apps\\openmw-tests FILES ${UNITTEST_SRC_FILES})
|
||||
|
||||
openmw_add_executable(openmw-tests ${UNITTEST_SRC_FILES})
|
||||
|
||||
target_link_libraries(openmw-tests
|
||||
GTest::GTest
|
||||
GMock::GMock
|
||||
openmw-lib
|
||||
)
|
||||
|
||||
# Fix for not visible pthreads functions for linker with glibc 2.15
|
||||
if (UNIX AND NOT APPLE)
|
||||
target_link_libraries(openmw-tests ${CMAKE_THREAD_LIBS_INIT})
|
||||
endif()
|
||||
|
||||
if (BUILD_WITH_CODE_COVERAGE)
|
||||
target_compile_options(openmw-tests PRIVATE --coverage)
|
||||
target_link_libraries(openmw-tests gcov)
|
||||
endif()
|
||||
|
||||
target_compile_definitions(openmw-tests
|
||||
PRIVATE OPENMW_DATA_DIR=u8"${CMAKE_CURRENT_BINARY_DIR}/data"
|
||||
OPENMW_PROJECT_SOURCE_DIR=u8"${PROJECT_SOURCE_DIR}")
|
||||
|
||||
if (MSVC AND PRECOMPILE_HEADERS_WITH_MSVC)
|
||||
target_precompile_headers(openmw-tests PRIVATE
|
||||
<boost/program_options/options_description.hpp>
|
||||
|
||||
<gtest/gtest.h>
|
||||
|
||||
<sol/sol.hpp>
|
||||
|
||||
<algorithm>
|
||||
<filesystem>
|
||||
<fstream>
|
||||
<functional>
|
||||
<memory>
|
||||
<string>
|
||||
<vector>
|
||||
)
|
||||
endif()
|
@ -0,0 +1,7 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
@ -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
|
Loading…
Reference in New Issue