Skip to content

Commit

Permalink
Merge pull request #1064 from CesiumGS/doctest
Browse files Browse the repository at this point in the history
Use doctest instead of Catch2 for tests
  • Loading branch information
kring authored Jan 16, 2025
2 parents 086f012 + 1c77901 commit 017d133
Show file tree
Hide file tree
Showing 104 changed files with 2,205 additions and 2,092 deletions.
2 changes: 1 addition & 1 deletion CMakeGraphVizOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ set(GRAPHVIZ_GENERATE_PER_TARGET FALSE)
set(GRAPHVIZ_GENERATE_DEPENDERS FALSE)
set(GRAPHVIZ_OBJECT_LIBS FALSE)
list(APPEND GRAPHVIZ_IGNORE_TARGETS cesium-native-tests)
list(APPEND GRAPHVIZ_IGNORE_TARGETS "Catch2::*")
list(APPEND GRAPHVIZ_IGNORE_TARGETS "doctest::*")
list(APPEND GRAPHVIZ_IGNORE_TARGETS "lib*.lib")
list(APPEND GRAPHVIZ_IGNORE_TARGETS "lib*.so")
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ set(PACKAGES_PRIVATE
)

# Packages only used for testing
set(PACKAGES_TEST catch2)
set(PACKAGES_TEST doctest)

if(NOT VCPKG_MANIFEST_MODE)
set(PACKAGES_ALL ${PACKAGES_PUBLIC})
Expand Down Expand Up @@ -241,7 +241,7 @@ list(APPEND CMAKE_PREFIX_PATH "${PACKAGE_BUILD_DIR}")
# and imporeted library target ourselves. This is the case for modp_b64::modp_b64, picosha2::picosha2 and earcut. In
# these cases, we *do* have the somewhat ugly and verbose details in the extern/CMakeLists.txt file.
find_package(Async++ CONFIG REQUIRED)
find_package(Catch2 CONFIG REQUIRED)
find_package(doctest CONFIG REQUIRED)
find_package(draco CONFIG REQUIRED)
find_package(expected-lite CONFIG REQUIRED)
find_package(glm CONFIG REQUIRED)
Expand Down
4 changes: 2 additions & 2 deletions Cesium3DTiles/test/TestMetadataQuery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
#include <Cesium3DTiles/Schema.h>
#include <CesiumUtility/JsonValue.h>

#include <catch2/catch_test_macros.hpp>
#include <doctest/doctest.h>

#include <optional>

using namespace Cesium3DTiles;
using namespace CesiumUtility;

TEST_CASE("MetadataQuery") {
SECTION("findFirstPropertyWithSemantic") {
SUBCASE("findFirstPropertyWithSemantic") {
Schema schema{};
Class& classDefinition =
schema.classes.emplace("someClass", Class()).first->second;
Expand Down
6 changes: 3 additions & 3 deletions Cesium3DTilesContent/test/TestB3dmToGltfConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <CesiumGltf/MeshPrimitive.h>
#include <CesiumGltf/Model.h>

#include <catch2/catch_test_macros.hpp>
#include <doctest/doctest.h>

#include <cstddef>
#include <filesystem>
Expand All @@ -17,7 +17,7 @@ using namespace Cesium3DTilesContent;
using namespace CesiumGltf;

TEST_CASE("B3dmToGltfConverter") {
SECTION("includes CESIUM_RTC extension in extensionsUsed") {
SUBCASE("includes CESIUM_RTC extension in extensionsUsed") {
std::filesystem::path testFilePath = Cesium3DTilesSelection_TEST_DATA_DIR;
testFilePath = testFilePath / "BatchTables" / "batchedWithJson.b3dm";

Expand All @@ -31,7 +31,7 @@ TEST_CASE("B3dmToGltfConverter") {
CHECK(gltf.isExtensionRequired(ExtensionCesiumRTC::ExtensionName));
}

SECTION("Index bufferViews created from Draco are valid") {
SUBCASE("Index bufferViews created from Draco are valid") {
std::filesystem::path testFilePath = Cesium3DTilesSelection_TEST_DATA_DIR;
testFilePath =
testFilePath / "BatchTables" / "batchedWithBatchTable-draco.b3dm";
Expand Down
8 changes: 4 additions & 4 deletions Cesium3DTilesContent/test/TestI3dmToGltfConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <CesiumGltf/ExtensionExtMeshGpuInstancing.h>
#include <CesiumGltf/ExtensionModelExtStructuralMetadata.h>

#include <catch2/catch_test_macros.hpp>
#include <doctest/doctest.h>
#include <glm/ext/vector_float3.hpp>
#include <glm/ext/vector_float4.hpp>

Expand All @@ -16,7 +16,7 @@ using namespace Cesium3DTilesContent;
using namespace CesiumGltf;

TEST_CASE("I3dmToGltfConverter") {
SECTION("loads a simple i3dm") {
SUBCASE("loads a simple i3dm") {
std::filesystem::path testFilePath = Cesium3DTilesSelection_TEST_DATA_DIR;
testFilePath = testFilePath / "i3dm" / "InstancedWithBatchTable" /
"instancedWithBatchTable.i3dm";
Expand All @@ -42,7 +42,7 @@ TEST_CASE("I3dmToGltfConverter") {
CHECK(translations.size() == 25);
}

SECTION("loads a simple i3dm with orientations") {
SUBCASE("loads a simple i3dm with orientations") {
std::filesystem::path testFilePath = Cesium3DTilesSelection_TEST_DATA_DIR;
testFilePath = testFilePath / "i3dm" / "InstancedOrientation" /
"instancedOrientation.i3dm";
Expand Down Expand Up @@ -75,7 +75,7 @@ TEST_CASE("I3dmToGltfConverter") {
CHECK(rotations.size() == 25);
}

SECTION("reports an error if the glTF is v1, which is unsupported") {
SUBCASE("reports an error if the glTF is v1, which is unsupported") {
std::filesystem::path testFilePath = Cesium3DTilesSelection_TEST_DATA_DIR;
testFilePath =
testFilePath / "i3dm" / "ObsoleteGltf" / "instancedWithBatchTable.i3dm";
Expand Down
50 changes: 25 additions & 25 deletions Cesium3DTilesContent/test/TestImplicitTilingUtilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <CesiumGeospatial/S2CellBoundingVolume.h>
#include <CesiumGeospatial/S2CellID.h>

#include <catch2/catch_test_macros.hpp>
#include <doctest/doctest.h>
#include <glm/ext/matrix_double3x3.hpp>
#include <libmorton/morton.h>

Expand All @@ -24,7 +24,7 @@ using namespace CesiumGeometry;
using namespace CesiumGeospatial;

TEST_CASE("ImplicitTilingUtilities child tile iteration") {
SECTION("QuadtreeTileID") {
SUBCASE("QuadtreeTileID") {
QuadtreeTileID parent(11, 2, 3);

QuadtreeChildren children = ImplicitTilingUtilities::getChildren(parent);
Expand Down Expand Up @@ -55,7 +55,7 @@ TEST_CASE("ImplicitTilingUtilities child tile iteration") {
CHECK(mismatch.second == expected.end());
}

SECTION("OctreeTileID") {
SUBCASE("OctreeTileID") {
OctreeTileID parent(11, 2, 3, 4);

OctreeChildren children = ImplicitTilingUtilities::getChildren(parent);
Expand Down Expand Up @@ -93,7 +93,7 @@ TEST_CASE("ImplicitTilingUtilities child tile iteration") {
}

TEST_CASE("ImplicitTilingUtilities::resolveUrl") {
SECTION("quadtree") {
SUBCASE("quadtree") {
QuadtreeTileID tileID(11, 2, 3);
std::string url = ImplicitTilingUtilities::resolveUrl(
"https://example.com",
Expand All @@ -102,7 +102,7 @@ TEST_CASE("ImplicitTilingUtilities::resolveUrl") {
CHECK(url == "https://example.com/tiles/11/2/3");
}

SECTION("octree") {
SUBCASE("octree") {
OctreeTileID tileID(11, 2, 3, 4);
std::string url = ImplicitTilingUtilities::resolveUrl(
"https://example.com",
Expand All @@ -113,14 +113,14 @@ TEST_CASE("ImplicitTilingUtilities::resolveUrl") {
}

TEST_CASE("ImplicitTilingUtilities::computeMortonIndex") {
SECTION("quadtree") {
SUBCASE("quadtree") {
QuadtreeTileID tileID(11, 2, 3);
CHECK(
ImplicitTilingUtilities::computeMortonIndex(tileID) ==
libmorton::morton2D_64_encode(2, 3));
}

SECTION("quadtree") {
SUBCASE("quadtree") {
OctreeTileID tileID(11, 2, 3, 4);
CHECK(
ImplicitTilingUtilities::computeMortonIndex(tileID) ==
Expand All @@ -129,15 +129,15 @@ TEST_CASE("ImplicitTilingUtilities::computeMortonIndex") {
}

TEST_CASE("ImplicitTilingUtilities::computeRelativeMortonIndex") {
SECTION("quadtree") {
SUBCASE("quadtree") {
QuadtreeTileID rootID(11, 2, 3);
QuadtreeTileID tileID(12, 5, 6);
CHECK(
ImplicitTilingUtilities::computeRelativeMortonIndex(rootID, tileID) ==
1);
}

SECTION("octree") {
SUBCASE("octree") {
OctreeTileID rootID(11, 2, 3, 4);
OctreeTileID tileID(12, 5, 6, 8);
CHECK(
Expand All @@ -147,7 +147,7 @@ TEST_CASE("ImplicitTilingUtilities::computeRelativeMortonIndex") {
}

TEST_CASE("ImplicitTilingUtilities::getSubtreeRootID") {
SECTION("quadtree") {
SUBCASE("quadtree") {
QuadtreeTileID tileID(10, 2, 3);
CHECK(
ImplicitTilingUtilities::getSubtreeRootID(5, tileID) ==
Expand All @@ -157,7 +157,7 @@ TEST_CASE("ImplicitTilingUtilities::getSubtreeRootID") {
QuadtreeTileID(8, 0, 0));
}

SECTION("octree") {
SUBCASE("octree") {
OctreeTileID tileID(10, 2, 3, 4);
CHECK(
ImplicitTilingUtilities::getSubtreeRootID(5, tileID) ==
Expand All @@ -169,7 +169,7 @@ TEST_CASE("ImplicitTilingUtilities::getSubtreeRootID") {
}

TEST_CASE("ImplicitTilingUtilities::absoluteTileIDToRelative") {
SECTION("quadtree") {
SUBCASE("quadtree") {
CHECK(
ImplicitTilingUtilities::absoluteTileIDToRelative(
QuadtreeTileID(0, 0, 0),
Expand All @@ -184,7 +184,7 @@ TEST_CASE("ImplicitTilingUtilities::absoluteTileIDToRelative") {
QuadtreeTileID(12, 5, 7)) == QuadtreeTileID(1, 1, 1));
}

SECTION("octree") {
SUBCASE("octree") {
CHECK(
ImplicitTilingUtilities::absoluteTileIDToRelative(
OctreeTileID(0, 0, 0, 0),
Expand All @@ -207,8 +207,8 @@ TEST_CASE("ImplicitTilingUtilities::computeLevelDenominator") {
}

TEST_CASE("ImplicitTilingUtilities::computeBoundingVolume") {
SECTION("OrientedBoundingBox") {
SECTION("quadtree") {
SUBCASE("OrientedBoundingBox") {
SUBCASE("quadtree") {
OrientedBoundingBox root(glm::dvec3(1.0, 2.0, 3.0), glm::dmat3(10.0));

OrientedBoundingBox l1x0y0 =
Expand All @@ -233,7 +233,7 @@ TEST_CASE("ImplicitTilingUtilities::computeBoundingVolume") {
CHECK(l1x0y1.getLengths() == glm::dvec3(10.0, 10.0, 20.0));
}

SECTION("octree") {
SUBCASE("octree") {
OrientedBoundingBox root(glm::dvec3(1.0, 2.0, 3.0), glm::dmat3(10.0));

OrientedBoundingBox l1x0y0z0 =
Expand Down Expand Up @@ -266,8 +266,8 @@ TEST_CASE("ImplicitTilingUtilities::computeBoundingVolume") {
}
}

SECTION("BoundingRegion") {
SECTION("quadtree") {
SUBCASE("BoundingRegion") {
SUBCASE("quadtree") {
BoundingRegion root(
GlobeRectangle(1.0, 2.0, 3.0, 4.0),
10.0,
Expand Down Expand Up @@ -308,7 +308,7 @@ TEST_CASE("ImplicitTilingUtilities::computeBoundingVolume") {
CHECK(l1x0y1.getMaximumHeight() == 20.0);
}

SECTION("octree") {
SUBCASE("octree") {
BoundingRegion root(
GlobeRectangle(1.0, 2.0, 3.0, 4.0),
10.0,
Expand Down Expand Up @@ -361,8 +361,8 @@ TEST_CASE("ImplicitTilingUtilities::computeBoundingVolume") {
}
}

SECTION("S2") {
SECTION("quadtree") {
SUBCASE("S2") {
SUBCASE("quadtree") {
S2CellBoundingVolume root(
S2CellID::fromQuadtreeTileID(1, QuadtreeTileID(0, 0, 0)),
10.0,
Expand Down Expand Up @@ -406,7 +406,7 @@ TEST_CASE("ImplicitTilingUtilities::computeBoundingVolume") {
CHECK(l1x0y1.getMaximumHeight() == 20.0);
}

SECTION("octree") {
SUBCASE("octree") {
S2CellBoundingVolume root(
S2CellID::fromQuadtreeTileID(1, QuadtreeTileID(0, 0, 0)),
10.0,
Expand Down Expand Up @@ -463,8 +463,8 @@ TEST_CASE("ImplicitTilingUtilities::computeBoundingVolume") {
}
}

SECTION("BoundingVolume") {
SECTION("quadtree") {
SUBCASE("BoundingVolume") {
SUBCASE("quadtree") {
BoundingVolume root{};

TileBoundingVolumes::setOrientedBoundingBox(
Expand Down Expand Up @@ -526,7 +526,7 @@ TEST_CASE("ImplicitTilingUtilities::computeBoundingVolume") {
CHECK(maybeS2->getMaximumHeight() == 20.0);
}

SECTION("octree") {
SUBCASE("octree") {
BoundingVolume root{};

TileBoundingVolumes::setOrientedBoundingBox(
Expand Down
4 changes: 2 additions & 2 deletions Cesium3DTilesContent/test/TestPntsToGltfConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
#include <CesiumGltf/Node.h>
#include <CesiumUtility/Math.h>

#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>
#include <doctest/doctest.h>
#include <glm/ext/vector_double3.hpp>
#include <glm/ext/vector_double4.hpp>
#include <glm/ext/vector_float3.hpp>
Expand All @@ -34,6 +33,7 @@
#include <string>
#include <vector>

using namespace doctest;
using namespace CesiumGltf;
using namespace Cesium3DTilesContent;
using namespace CesiumUtility;
Expand Down
Loading

0 comments on commit 017d133

Please sign in to comment.