Skip to content

Commit

Permalink
Initial support for building tests with CMake
Browse files Browse the repository at this point in the history
test/drtest binary is now built by CMake, but is not yet installed or run.
  • Loading branch information
Matthew Mott committed Dec 13, 2020
1 parent 62c3332 commit 9960f41
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
8 changes: 8 additions & 0 deletions CMakeLists.txt
Expand Up @@ -55,6 +55,7 @@ pkg_check_modules(PNG libpng REQUIRED)
pkg_check_modules(AL openal REQUIRED)
pkg_check_modules(OGG ogg REQUIRED)
pkg_check_modules(VORBIS vorbisfile REQUIRED)
pkg_check_modules(X11 x11 REQUIRED)

# Locate wxWidgets
find_package(wxWidgets REQUIRED
Expand Down Expand Up @@ -102,6 +103,13 @@ endif()
add_subdirectory(radiantcore)
add_subdirectory(radiant)

# Tests
pkg_check_modules(GTEST gtest)
pkg_check_modules(GTEST_MAIN gtest_main)
if (${GTEST_FOUND} AND ${GTEST_MAIN_FOUND})
add_subdirectory(test)
endif()

# Install main targets
install(TARGETS darkradiant math xmlutil scenegraph wxutil
LIBRARY DESTINATION ${PKGLIBDIR})
Expand Down
30 changes: 30 additions & 0 deletions test/CMakeLists.txt
@@ -0,0 +1,30 @@
add_executable(drtest
Camera.cpp
ColourSchemes.cpp
CSG.cpp
Face.cpp
FacePlane.cpp
FileTypes.cpp
HeadlessOpenGLContext.cpp
MapExport.cpp
MapSavingLoading.cpp
Materials.cpp
math/Matrix4.cpp
math/Plane3.cpp
math/Quaternion.cpp
math/Vector3.cpp
MessageBus.cpp
ModelExport.cpp
ModelScale.cpp
Models.cpp
PatchIterators.cpp
PatchWelding.cpp
SelectionAlgorithm.cpp
Selection.cpp
VFS.cpp
WorldspawnColour.cpp)
target_compile_options(drtest PRIVATE ${SIGC_CFLAGS})
target_link_libraries(drtest PRIVATE
math xmlutil module
${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES}
${SIGC_LIBRARIES} ${GLEW_LIBRARIES} ${X11_LIBRARIES})
4 changes: 2 additions & 2 deletions test/PatchWelding.cpp
Expand Up @@ -203,15 +203,15 @@ TEST_F(PatchWeldingTest, WeldingPreservesFixedSubdivisions)

// Check the setup
EXPECT_TRUE(firstPatchNode->getPatch().subdivisionsFixed()) << "Patch 1 isn't set to fixed subdivisions 5x2, test map changed?";
EXPECT_EQ(firstPatchNode->getPatch().getSubdivisions(), Subdivisions({ 5, 2 })) << "Patch 1 isn't set to fixed subdivisions 5x2, test map changed?";
EXPECT_EQ(firstPatchNode->getPatch().getSubdivisions(), Subdivisions(5, 2)) << "Patch 1 isn't set to fixed subdivisions 5x2, test map changed?";

// After merging we expect the merged patch to have the same subdivisions as patch 1 had
auto mergedNode = performPatchWelding("1", "2");

auto merged = std::dynamic_pointer_cast<IPatchNode>(mergedNode);

EXPECT_TRUE(merged->getPatch().subdivisionsFixed()) << "Merged patch is supposed to have fixed subdivisions 5x2";
EXPECT_EQ(merged->getPatch().getSubdivisions(), Subdivisions({ 5, 2 })) << "Merged patch is supposed to have fixed subdivisions 5x2";
EXPECT_EQ(merged->getPatch().getSubdivisions(), Subdivisions(5, 2)) << "Merged patch is supposed to have fixed subdivisions 5x2";
}

TEST_F(PatchWeldingTest, WeldingPreservesNonfixedSubdivisions)
Expand Down

0 comments on commit 9960f41

Please sign in to comment.