tests: port DiscreteEllipticUtility + P2 tests; stub HDS-blocked tests
Fully ported (pure math, no HDS required):
test_discrete_elliptic_utility.cpp – 2 tests
normalizeModulus: move tau into SL(2,Z) fundamental domain
test_p2_utility.cpp – 3 tests
P2 projective geometry (perpendicularBisector, pointFromLines,
makeDirectIsometryFromFrames double vs long double precision)
New headers:
include/discrete_elliptic_utility.hpp – normalizeModulus
include/p2_utility.hpp – P2 Euclidean geometry (templated
on scalar type so double and long double share one implementation)
Stubs (GTEST_SKIP, blocked until HDS port – Phase 4):
test_hyper_ideal_functional.cpp – 5 tests (1 @Ignore in Java)
test_hyper_ideal_hyperelliptic_utility.cpp – 3 tests
test_spherical_functional.cpp – 5 tests
All use CoHDS + HalfEdgeUtils which are not yet ported to C++.
Result: 34 tests total | 21 passed | 13 skipped | 0 failed
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
39
code/tests/test_discrete_elliptic_utility.cpp
Normal file
39
code/tests/test_discrete_elliptic_utility.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
// Port of de.varylab.discreteconformal.util.DiscreteEllipticUtilityTest (Java/JUnit).
|
||||
// Tests the normalizeModulus function that moves a complex number tau into the
|
||||
// fundamental domain of the modular group SL(2,Z).
|
||||
|
||||
#include "discrete_elliptic_utility.hpp"
|
||||
#include <gtest/gtest.h>
|
||||
#include <complex>
|
||||
#include <cmath>
|
||||
|
||||
using namespace conformallab;
|
||||
|
||||
// Corresponds to Java testNormalizeModulus()
|
||||
TEST(DiscreteEllipticUtilityTest, NormalizeModulus) {
|
||||
// tau already in fundamental domain → should be returned unchanged
|
||||
std::complex<double> tau(0.45, 1.1);
|
||||
auto tauNorm = normalizeModulus(tau);
|
||||
EXPECT_NEAR(0.45, tauNorm.real(), 1E-12);
|
||||
EXPECT_NEAR(1.1, tauNorm.imag(), 1E-12);
|
||||
|
||||
// tau = i/3 (|tau| < 1) → inversion gives 3i
|
||||
tau = std::complex<double>(0.0, 1.0 / 3.0);
|
||||
tauNorm = normalizeModulus(tau);
|
||||
EXPECT_NEAR(3.0, tauNorm.imag(), 1E-12);
|
||||
EXPECT_NEAR(0.0, tauNorm.real(), 1E-12);
|
||||
}
|
||||
|
||||
// Corresponds to Java testNormalizeModulusPeriodShift()
|
||||
// Two tau values that differ by a T-shift (integer shift of Re) must normalize
|
||||
// to the same point in the fundamental domain.
|
||||
TEST(DiscreteEllipticUtilityTest, NormalizeModulusPeriodShift) {
|
||||
std::complex<double> tau1(0.3, 1.0);
|
||||
std::complex<double> tau2(-0.7, 1.0); // tau2 = tau1 - 1
|
||||
|
||||
auto n1 = normalizeModulus(tau1);
|
||||
auto n2 = normalizeModulus(tau2);
|
||||
|
||||
EXPECT_NEAR(n1.real(), n2.real(), 1E-12) << "real parts should be equal";
|
||||
EXPECT_NEAR(n1.imag(), n2.imag(), 1E-12) << "imag parts should be equal";
|
||||
}
|
||||
Reference in New Issue
Block a user