Running the unit tests locally
EBGeometry ships a Catch2 v3 unit
test suite under Tests/. Catch2 is fetched automatically at CMake configure
time via FetchContent — no manual installation is needed.
On this page
Quick start with CMake presets
The repository ships CMakePresets.json (requires CMake 3.22+) with
pre-configured debug and release profiles. The debug preset is the
recommended starting point: it enables assertions, disables SIMD (cleaner
debugger output), and turns on both the test suite and the examples.
# 1. Configure (Catch2 is fetched automatically on the first run)
cmake --preset debug
# 2. Build
cmake --build --preset debug --parallel $(nproc)
# 3a. Run unit tests only (< 1 s)
ctest --preset debug
# 3b. Run example programs (allow several minutes in Debug mode)
ctest --preset examples
A successful unit-test run looks like:
100% tests passed, 0 tests failed out of 220
Label Time Summary:
unit = 1.43 sec*proc (220 tests)
Most test files are written with Catch2’s TEMPLATE_TEST_CASE so they can run under both
float and double, but locally, by default, only double runs (fast iteration,
matching whatever the CMake preset otherwise builds) – the count above is double-only. CI
additionally configures with -DEBGEOMETRY_TEST_BOTH_PRECISIONS=ON to run the full suite
under both precisions (422 tests). To do the same locally:
cmake --preset debug -DEBGEOMETRY_TEST_BOTH_PRECISIONS=ON
cmake --build --preset debug --parallel $(nproc)
ctest --preset debug
Running with sanitizers (AddressSanitizer + UBSan)
cmake --preset debug-san
cmake --build --preset debug-san --parallel $(nproc)
ctest --preset debug-san
Preset reference
Preset |
Build type |
Assertions |
SIMD |
Tests / Examples |
|---|---|---|---|---|
|
|
ON |
none |
Unit tests + examples (labelled separately) |
|
|
ON |
none |
Unit tests + examples with ASan/UBSan |
|
|
OFF |
avx |
OFF (library only) |
|
|
OFF |
avx |
Unit tests + examples |
Manual CMake options (without presets)
If you cannot use presets (CMake < 3.22 or an IDE that does not support them), pass the variables directly:
cmake -B build \
-DCMAKE_BUILD_TYPE=Debug \
-DEBGEOMETRY_BUILD_TESTS=ON \
-DEBGEOMETRY_ENABLE_ASSERTIONS=ON \
-DEBGEOMETRY_SIMD=none
cmake --build build --parallel $(nproc)
cd build && ctest -L unit --output-on-failure
CMake options
Option |
Default |
Effect |
|---|---|---|
|
|
Fetch Catch2 and build the |
|
|
Build the standalone examples under |
|
|
Compile with |
|
|
Add |
|
|
|
Selecting individual tests
Catch2 test cases are registered with CTest so you can filter by name or tag:
# Run only the Vec tests
ctest --output-on-failure -R "Vec3T"
# Run only the SFC tests
ctest --output-on-failure -R "SFC"
# Run a single test binary directly (all Catch2 options available).
# Each preset gets its own build directory (build/<preset-name>/...); adjust
# the path if you configured with a preset instead of the manual example above.
./Tests/TestVec --list-tests
./Tests/TestAnalyticSDF "[SphereSDF]"
Test coverage
Test binary |
What is covered |
|---|---|
|
|
|
|
|
|
|
DCEL topology of a hardcoded tetrahedron (face/vertex/edge counts,
half-edge pairing, unit normals, |
|
|
|
|
|
|
|
|
|
|
|
|
|
A regular dodecahedron (20 vertices, 36 triangulated faces), read from disk in all four
supported formats, used to verify: identical topology/geometry across formats;
|
|
|
|
|
|
|
|
|
|
|
|
|
Tests/InstantiateAll.cpp is not itself a test binary and does not appear in the table
above: it is a compile-only target (built by cmake --build, but never run by ctest)
that explicitly instantiates every public class template for both float and double.
Its purpose is to give clang-tidy and the project’s warning set (in particular
-Wdouble-promotion) something to analyse for both precisions, regardless of what the
Catch2 tests above happen to exercise – float support would otherwise only be checked
by whichever public classes a test happens to instantiate. See
Contribution guidelines for when to add a new class to it.
Note
All of the mesh- and BVH-related tests above rely on the sign convention (negative inside, positive outside) and face-normal computation described in Geometry representations and Half-edge meshes (DCEL) – see those pages rather than this one for the convention itself.