diff --git a/Tests/UnitTests/Core/CMakeLists.txt b/Tests/UnitTests/Core/CMakeLists.txt index 9aa0602db989533384a9e7d1c32921461d755994..f2b228a4dd2acc47e1aba07ca0365bd8596c51a8 100644 --- a/Tests/UnitTests/Core/CMakeLists.txt +++ b/Tests/UnitTests/Core/CMakeLists.txt @@ -32,4 +32,3 @@ ADD_GTEST(Core "DataStructure" ${libs} 0) ADD_GTEST(Core "Other" ${libs} 0) ADD_GTEST(Core "Numeric0" ${libs} 1) ADD_GTEST(Core "Numeric1" ${libs} 1) -ADD_GTEST(Core "Numeric2" ${libs} 0) diff --git a/Tests/UnitTests/Core/Numeric0/FormFactorSpecializationTest.h b/Tests/UnitTests/Core/Numeric0/FormFactorSpecializationTest.h index 94453e741768164a7faf6d51a1fa9f459d2d01b8..88f751d24f4281b4af2a69146a64c2cf1aa060c1 100644 --- a/Tests/UnitTests/Core/Numeric0/FormFactorSpecializationTest.h +++ b/Tests/UnitTests/Core/Numeric0/FormFactorSpecializationTest.h @@ -1,112 +1,93 @@ #include "google_test.h" -#include "MathConstants.h" -#include "BornAgainNamespace.h" -#include "HardParticles.h" -#include "qLoopedTest.h" +#include "FormFactorTest.h" -class FFSpecializationTest : public QLoopedTest +class FFSpecializationTest : public FormFactorTest { -public: - void test_ff_eq(IFormFactorBorn* p0, IFormFactorBorn* p1, double eps=1e-12) { - complex_t f0 = p0->evaluate_for_q(q); - complex_t f1 = p1->evaluate_for_q(q); +protected: + ~FFSpecializationTest(); + + void run_test(IFormFactorBorn* p0, IFormFactorBorn* p1, double eps, double qmag1, double qmag2) + { + test_all(qmag1, qmag2, [&](){test_ff_eq(p0, p1, eps);}); + } + + void test_ff_eq(IFormFactorBorn* p0, IFormFactorBorn* p1, double eps) { + complex_t f0 = p0->evaluate_for_q(m_q); + complex_t f1 = p1->evaluate_for_q(m_q); double avge = (std::abs(f0) + std::abs(f1))/2; - //std::cout<<"q="<<q<<" -> "<<std::setprecision(16)<<" f0="<<f0<<", f1="<<f1<<"\n"; EXPECT_NEAR( real(f0), real(f1), eps*avge ); EXPECT_NEAR( imag(f0), imag(f1), eps*avge ); } - ~FFSpecializationTest(); + + static double eps_polyh; }; FFSpecializationTest::~FFSpecializationTest() = default; +double FFSpecializationTest::eps_polyh = 7.5e-13; -INSTANTIATE_TEST_CASE_P( - FFSpecializationTests, - FFSpecializationTest, - qlist); - -//*********** polyhedra *************** - -double eps_polyh = 7.5e-13; - -TEST_P(FFSpecializationTest, TruncatedCubeAsBox) +TEST_F(FFSpecializationTest, TruncatedCubeAsBox) { - if (skip_q(1e-99, 5e2)) - return; - double L = .5; + const double L = .5; FormFactorTruncatedCube p0(L, 0); FormFactorBox p1(L, L, L); - test_ff_eq(&p0, &p1, eps_polyh); + run_test(&p0, &p1, eps_polyh, 1e-99, 5e2); } -TEST_P(FFSpecializationTest, AnisoPyramidAsPyramid) +TEST_F(FFSpecializationTest, AnisoPyramidAsPyramid) { - if (skip_q(1e-99, 5e3)) - return; - double L = 1.5, H = .24, alpha = .6; + const double L = 1.5, H = .24, alpha = .6; FormFactorAnisoPyramid p0(L, L, H, alpha); FormFactorPyramid p1(L, H, alpha); - test_ff_eq(&p0, &p1, eps_polyh); + run_test(&p0, &p1, eps_polyh, 1e-99, 5e3); } -TEST_P(FFSpecializationTest, Pyramid3AsPrism) +TEST_F(FFSpecializationTest, Pyramid3AsPrism) { - if (skip_q(1e-99, 5e3)) - return; - double L = 1.8, H = .3; + const double L = 1.8, H = .3; FormFactorTetrahedron p0(L, H, M_PI / 2); FormFactorPrism3 p1(L, H); - test_ff_eq(&p0, &p1, eps_polyh); + run_test(&p0, &p1, eps_polyh, 1e-99, 5e3); } -TEST_P(FFSpecializationTest, PyramidAsBox) +TEST_F(FFSpecializationTest, PyramidAsBox) { - if (skip_q(1e-99, 5e2)) - return; - double L = 1.8, H = .3; + const double L = 1.8, H = .3; FormFactorPyramid p0(L, H, M_PI / 2); FormFactorBox p1(L, L, H); - test_ff_eq(&p0, &p1, eps_polyh); + run_test(&p0, &p1, eps_polyh, 1e-99, 5e2); } -TEST_P(FFSpecializationTest, Cone6AsPrism) +TEST_F(FFSpecializationTest, Cone6AsPrism) { - if (skip_q(1e-99, 5e2)) - return; - double L = .8, H = 1.13; + const double L = .8, H = 1.13; FormFactorCone6 p0(L, H, M_PI / 2); FormFactorPrism6 p1(L, H); - test_ff_eq(&p0, &p1, eps_polyh); + run_test(&p0, &p1, eps_polyh, 1e-99, 5e2); } //*********** spheroids *************** -TEST_P(FFSpecializationTest, HemiEllipsoidAsTruncatedSphere) +TEST_F(FFSpecializationTest, HemiEllipsoidAsTruncatedSphere) { - if (skip_q(1e-99, 5e2)) - return; - double R = 1.07; + const double R = 1.07; FormFactorHemiEllipsoid p0(R, R, R); FormFactorTruncatedSphere p1(R, R); - test_ff_eq(&p0, &p1, 1e-10); + run_test(&p0, &p1, 1e-10, 1e-99, 5e2); } -TEST_P(FFSpecializationTest, EllipsoidalCylinderAsCylinder) +TEST_F(FFSpecializationTest, EllipsoidalCylinderAsCylinder) { - if (skip_q(1e-99, 5e3)) - return; - double R = .8, H = 1.2; + const double R = .8, H = 1.2; FormFactorEllipsoidalCylinder p0(R, R, H); FormFactorCylinder p1(R, H); - test_ff_eq(&p0, &p1, 1e-11); + run_test(&p0, &p1, 1e-11, 1e-99, 5e3); } -TEST_P(FFSpecializationTest, TruncatedSphereAsSphere) +TEST_F(FFSpecializationTest, TruncatedSphereAsSphere) { - if (skip_q(.02, 5e1)) // WAITING #1416 improve/replace numeric integration - return; - double R = 1.; + const double R = 1.; FormFactorTruncatedSphere p0(R, 2 * R); FormFactorFullSphere p1(R); - test_ff_eq(&p0, &p1); + run_test(&p0, &p1, 1e-12, .02, 5e1); } + diff --git a/Tests/UnitTests/Core/Numeric0/FormFactorSpecializationTest2.h b/Tests/UnitTests/Core/Numeric0/FormFactorSpecializationTest2.h deleted file mode 100644 index 57d8a87d921b6c5675a4dddb2f6c0f2b9c17d275..0000000000000000000000000000000000000000 --- a/Tests/UnitTests/Core/Numeric0/FormFactorSpecializationTest2.h +++ /dev/null @@ -1,93 +0,0 @@ -#include "google_test.h" -#include "FormFactorTest.h" - -class FFSpecializationTest2 : public FormFactorTest -{ -protected: - ~FFSpecializationTest2(); - - void run_test(IFormFactorBorn* p0, IFormFactorBorn* p1, double eps, double qmag1, double qmag2) - { - test_all(qmag1, qmag2, [&](){test_ff_eq(p0, p1, eps);}); - } - - void test_ff_eq(IFormFactorBorn* p0, IFormFactorBorn* p1, double eps) { - complex_t f0 = p0->evaluate_for_q(m_q); - complex_t f1 = p1->evaluate_for_q(m_q); - double avge = (std::abs(f0) + std::abs(f1))/2; - EXPECT_NEAR( real(f0), real(f1), eps*avge ); - EXPECT_NEAR( imag(f0), imag(f1), eps*avge ); - } - - static double eps_polyh; -}; - -FFSpecializationTest2::~FFSpecializationTest2() = default; -double FFSpecializationTest2::eps_polyh = 7.5e-13; - -TEST_F(FFSpecializationTest2, TruncatedCubeAsBox) -{ - const double L = .5; - FormFactorTruncatedCube p0(L, 0); - FormFactorBox p1(L, L, L); - run_test(&p0, &p1, eps_polyh, 1e-99, 5e2); -} - -TEST_F(FFSpecializationTest2, AnisoPyramidAsPyramid) -{ - const double L = 1.5, H = .24, alpha = .6; - FormFactorAnisoPyramid p0(L, L, H, alpha); - FormFactorPyramid p1(L, H, alpha); - run_test(&p0, &p1, eps_polyh, 1e-99, 5e3); -} - -TEST_F(FFSpecializationTest2, Pyramid3AsPrism) -{ - const double L = 1.8, H = .3; - FormFactorTetrahedron p0(L, H, M_PI / 2); - FormFactorPrism3 p1(L, H); - run_test(&p0, &p1, eps_polyh, 1e-99, 5e3); -} - -TEST_F(FFSpecializationTest2, PyramidAsBox) -{ - const double L = 1.8, H = .3; - FormFactorPyramid p0(L, H, M_PI / 2); - FormFactorBox p1(L, L, H); - run_test(&p0, &p1, eps_polyh, 1e-99, 5e2); -} - -TEST_F(FFSpecializationTest2, Cone6AsPrism) -{ - const double L = .8, H = 1.13; - FormFactorCone6 p0(L, H, M_PI / 2); - FormFactorPrism6 p1(L, H); - run_test(&p0, &p1, eps_polyh, 1e-99, 5e2); -} - -//*********** spheroids *************** - -TEST_F(FFSpecializationTest2, HemiEllipsoidAsTruncatedSphere) -{ - const double R = 1.07; - FormFactorHemiEllipsoid p0(R, R, R); - FormFactorTruncatedSphere p1(R, R); - run_test(&p0, &p1, 1e-10, 1e-99, 5e2); -} - -TEST_F(FFSpecializationTest2, EllipsoidalCylinderAsCylinder) -{ - const double R = .8, H = 1.2; - FormFactorEllipsoidalCylinder p0(R, R, H); - FormFactorCylinder p1(R, H); - run_test(&p0, &p1, 1e-11, 1e-99, 5e3); -} - -TEST_F(FFSpecializationTest2, TruncatedSphereAsSphere) -{ - const double R = 1.; - FormFactorTruncatedSphere p0(R, 2 * R); - FormFactorFullSphere p1(R); - run_test(&p0, &p1, 1e-12, .02, 5e1); -} - diff --git a/Tests/UnitTests/Core/Numeric0/testlist.h b/Tests/UnitTests/Core/Numeric0/testlist.h index 7ee1d46d2251c7d2f4557d738c5d00e1429407fd..6afe17994500c147c393504aad7f593f58537e35 100644 --- a/Tests/UnitTests/Core/Numeric0/testlist.h +++ b/Tests/UnitTests/Core/Numeric0/testlist.h @@ -1,4 +1,3 @@ // To renew this file, run /G/ba/dev-tools/code-tools/update-gtestlist.py <directory> -//#include "FormFactorSpecializationTest.h" -#include "FormFactorSpecializationTest2.h" +#include "FormFactorSpecializationTest.h" diff --git a/Tests/UnitTests/Core/Numeric1/FormFactorSymmetryTest.h b/Tests/UnitTests/Core/Numeric1/FormFactorSymmetryTest.h index 7cd33cd01fbbede05c24fc367af1fe3ecdcdd6c6..ff9f64d0d539920d63a7ba7b33133ca05fc0077e 100644 --- a/Tests/UnitTests/Core/Numeric1/FormFactorSymmetryTest.h +++ b/Tests/UnitTests/Core/Numeric1/FormFactorSymmetryTest.h @@ -1,107 +1,89 @@ #include "google_test.h" +#include "FormFactorTest.h" #include "MathConstants.h" -#include "BornAgainNamespace.h" -#include "HardParticles.h" -#include "qLoopedTest.h" +#include <functional> -class FFSymmetryTest : public QLoopedTest +class FFSymmetryTest : public FormFactorTest { public: ~FFSymmetryTest(); - void test_qq_eq( IFormFactorBorn* p, cvector_t q0, cvector_t q1, double eps=1e-12 ) { - - std::cout - << q0.x().real() << " " - << q0.x().imag() << " " - << q0.y().real() << " " - << q0.y().imag() << " " - << q0.z().real() << " " - << q0.z().imag() << " " - << q1.x().real() << " " - << q1.x().imag() << " " - << q1.y().real() << " " - << q1.y().imag() << " " - << q1.z().real() << " " - << q1.z().imag() << " " - << std::endl; - - complex_t f0 = p->evaluate_for_q(q0); - complex_t f1 = p->evaluate_for_q(q1); + + using transform_t = std::function<cvector_t(const cvector_t&)>; + + void run_test(IFormFactorBorn* p, transform_t fun, double eps, double qmag1, double qmag2) + { + test_all(qmag1, qmag2, [&](){test_qq_eq(p, fun, eps);}); + } + + void test_qq_eq( IFormFactorBorn* p, transform_t fun, double eps=1e-12 ) { + complex_t f0 = p->evaluate_for_q(m_q); + complex_t f1 = p->evaluate_for_q(fun(m_q)); double avge = (std::abs(f0) + std::abs(f1))/2; EXPECT_NEAR( real(f0), real(f1), eps*avge ); EXPECT_NEAR( imag(f0), imag(f1), eps*avge ); } - cvector_t qt; + }; FFSymmetryTest::~FFSymmetryTest() = default; -INSTANTIATE_TEST_CASE_P( - FFSymmetryTests, - FFSymmetryTest, - qlist); - //*********** polyhedra *************** -//TEST_P(FFSymmetryTest, Prism3) -//{ -// if (skip_q(1e-99, 2e2)) -// return; -// FormFactorPrism3 p(.83, .45); -// test_qq_eq(&p, q, q.rotatedZ(M_TWOPI / 3)); -//} - -//TEST_P(FFSymmetryTest, Prism6) -//{ -// if (skip_q(1e-99, 2e3)) -// return; -// FormFactorPrism6 p(1.33, .42); -// test_qq_eq(&p, q, q.rotatedZ(M_PI / 3), 1e-12); -// test_qq_eq(&p, q, q.rotatedZ(-M_TWOPI / 3), 3.8e-12); -//} - -//TEST_P(FFSymmetryTest, Tetrahedron) -//{ -// if (skip_q(1e-99, 2e2)) -// return; -// FormFactorTetrahedron p(8.43, .25, .53); -// test_qq_eq(&p, q, q.rotatedZ(M_TWOPI / 3), 6e-12); -// // Linux: 3e-12, relaxed for Mac -//} - -//TEST_P(FFSymmetryTest, Cone6_flat) -//{ -// if (skip_q(1e-99, 2e2)) // TODO for larger q, imag(ff) is nan -// return; -// FormFactorCone6 p(4.3, .09, .1); -// test_qq_eq(&p, q, q.rotatedZ(-M_PI / 3), 3.8e-12); -//} - -//TEST_P(FFSymmetryTest, Cone6_steep) -//{ -// if (skip_q(1e-99, 2e2)) // TODO for larger q, imag(ff) is nan -// return; -// FormFactorCone6 p(.23, 3.5, .999 * M_PI / 2); -// test_qq_eq(&p, q, q.rotatedZ(-M_PI / 3), 2.5e-12); -//} +TEST_F(FFSymmetryTest, Prism3) +{ + FormFactorPrism3 p(.83, .45); + run_test(&p, [](const cvector_t& q)->cvector_t{return q.rotatedZ(M_TWOPI / 3);}, + 1e-12, 1e-99, 2e2); +} + +TEST_F(FFSymmetryTest, Prism6) +{ + FormFactorPrism6 p(1.33, .42); + run_test(&p, [](const cvector_t& q)->cvector_t{return q.rotatedZ(M_PI / 3);}, + 1e-12, 1e-99, 2e3); + run_test(&p, [](const cvector_t& q)->cvector_t{return q.rotatedZ(-M_TWOPI / 3);}, + 3.8e-12, 1e-99, 2e3); +} + +TEST_F(FFSymmetryTest, Tetrahedron) +{ + FormFactorTetrahedron p(8.43, .25, .53); + run_test(&p, [](const cvector_t& q)->cvector_t{return q.rotatedZ(M_TWOPI / 3);}, + 6e-12, 1e-99, 2e2); + // Linux: 3e-12, relaxed for Mac +} + +TEST_F(FFSymmetryTest, Cone6_flat) +{ + // TODO for larger q, imag(ff) is nan + FormFactorCone6 p(4.3, .09, .1); + run_test(&p, [](const cvector_t& q)->cvector_t{return q.rotatedZ(-M_PI / 3);}, + 3.8e-12, 1e-99, 2e2); +} + +TEST_F(FFSymmetryTest, Cone6_steep) +{ + FormFactorCone6 p(.23, 3.5, .999 * M_PI / 2); + run_test(&p, [](const cvector_t& q)->cvector_t{return q.rotatedZ(-M_PI / 3);}, + 2.5e-12, 1e-99, 2e2); +} //*********** spheroids *************** -TEST_P(FFSymmetryTest, HemiEllipsoid) +TEST_F(FFSymmetryTest, HemiEllipsoid) { - if (skip_q(1e-99, 2e2)) - return; FormFactorHemiEllipsoid p(.53, .78, 1.3); - test_qq_eq(&p, q, cvector_t(-q.x(), q.y(), q.z())); - test_qq_eq(&p, q, cvector_t(q.x(), -q.y(), q.z())); + run_test(&p, [](const cvector_t& q)->cvector_t{return cvector_t(-q.x(), q.y(), q.z());}, + 1e-12, 1e-99, 2e2); + run_test(&p, [](const cvector_t& q)->cvector_t{return cvector_t(q.x(), -q.y(), q.z());}, + 1e-12, 1e-99, 2e2); } -//TEST_P(FFSymmetryTest, TruncatedSphere) -//{ -// if (skip_q(1e-99, 2e2)) -// return; -// FormFactorTruncatedSphere p(.79, .34); -// test_qq_eq(&p, q, q.rotatedZ(M_PI / 3.13698), 1e-10); -//} +TEST_F(FFSymmetryTest, TruncatedSphere) +{ + FormFactorTruncatedSphere p(.79, .34); + run_test(&p, [](const cvector_t& q)->cvector_t{return q.rotatedZ(M_PI / 3.13698);}, + 1e-10, 1e-99, 2e2); +} // ****** TODO: tests that do not pass for the full q range ********* diff --git a/Tests/UnitTests/Core/Numeric1/FormFactorSymmetryTest2.h b/Tests/UnitTests/Core/Numeric1/FormFactorSymmetryTest2.h deleted file mode 100644 index ba86ab3febb0b3be13d9c5c0daa3de45345634bd..0000000000000000000000000000000000000000 --- a/Tests/UnitTests/Core/Numeric1/FormFactorSymmetryTest2.h +++ /dev/null @@ -1,89 +0,0 @@ -#include "google_test.h" -#include "FormFactorTest.h" -#include "MathConstants.h" -#include <functional> - -class FFSymmetryTest2 : public FormFactorTest -{ -public: - ~FFSymmetryTest2(); - - using transform_t = std::function<cvector_t(const cvector_t&)>; - - void run_test(IFormFactorBorn* p, transform_t fun, double eps, double qmag1, double qmag2) - { - test_all(qmag1, qmag2, [&](){test_qq_eq(p, fun, eps);}); - } - - void test_qq_eq( IFormFactorBorn* p, transform_t fun, double eps=1e-12 ) { - complex_t f0 = p->evaluate_for_q(m_q); - complex_t f1 = p->evaluate_for_q(fun(m_q)); - double avge = (std::abs(f0) + std::abs(f1))/2; - EXPECT_NEAR( real(f0), real(f1), eps*avge ); - EXPECT_NEAR( imag(f0), imag(f1), eps*avge ); - } - -}; - -FFSymmetryTest2::~FFSymmetryTest2() = default; - -//*********** polyhedra *************** - -TEST_F(FFSymmetryTest2, Prism3) -{ - FormFactorPrism3 p(.83, .45); - run_test(&p, [](const cvector_t& q)->cvector_t{return q.rotatedZ(M_TWOPI / 3);}, - 1e-12, 1e-99, 2e2); -} - -TEST_F(FFSymmetryTest2, Prism6) -{ - FormFactorPrism6 p(1.33, .42); - run_test(&p, [](const cvector_t& q)->cvector_t{return q.rotatedZ(M_PI / 3);}, - 1e-12, 1e-99, 2e3); - run_test(&p, [](const cvector_t& q)->cvector_t{return q.rotatedZ(-M_TWOPI / 3);}, - 3.8e-12, 1e-99, 2e3); -} - -TEST_F(FFSymmetryTest2, Tetrahedron) -{ - FormFactorTetrahedron p(8.43, .25, .53); - run_test(&p, [](const cvector_t& q)->cvector_t{return q.rotatedZ(M_TWOPI / 3);}, - 6e-12, 1e-99, 2e2); - // Linux: 3e-12, relaxed for Mac -} - -TEST_F(FFSymmetryTest2, Cone6_flat) -{ - // TODO for larger q, imag(ff) is nan - FormFactorCone6 p(4.3, .09, .1); - run_test(&p, [](const cvector_t& q)->cvector_t{return q.rotatedZ(-M_PI / 3);}, - 3.8e-12, 1e-99, 2e2); -} - -TEST_F(FFSymmetryTest2, Cone6_steep) -{ - FormFactorCone6 p(.23, 3.5, .999 * M_PI / 2); - run_test(&p, [](const cvector_t& q)->cvector_t{return q.rotatedZ(-M_PI / 3);}, - 2.5e-12, 1e-99, 2e2); -} - -//*********** spheroids *************** - -TEST_F(FFSymmetryTest2, HemiEllipsoid) -{ - FormFactorHemiEllipsoid p(.53, .78, 1.3); - run_test(&p, [](const cvector_t& q)->cvector_t{return cvector_t(-q.x(), q.y(), q.z());}, - 1e-12, 1e-99, 2e2); - run_test(&p, [](const cvector_t& q)->cvector_t{return cvector_t(q.x(), -q.y(), q.z());}, - 1e-12, 1e-99, 2e2); -} - -TEST_F(FFSymmetryTest2, TruncatedSphere) -{ - FormFactorTruncatedSphere p(.79, .34); - run_test(&p, [](const cvector_t& q)->cvector_t{return q.rotatedZ(M_PI / 3.13698);}, - 1e-10, 1e-99, 2e2); -} - -// ****** TODO: tests that do not pass for the full q range ********* diff --git a/Tests/UnitTests/Core/Numeric1/testlist.h b/Tests/UnitTests/Core/Numeric1/testlist.h index e7010587b623283cf6182414d9cfaa42a282da2b..b7b4f983c36b3deacfa81336180291946c18fd70 100644 --- a/Tests/UnitTests/Core/Numeric1/testlist.h +++ b/Tests/UnitTests/Core/Numeric1/testlist.h @@ -1,4 +1,4 @@ // To renew this file, run /G/ba/dev-tools/code-tools/update-gtestlist.py <directory> -//#include "FormFactorSymmetryTest.h" -#include "FormFactorSymmetryTest2.h" +#include "FormFactorSymmetryTest.h" + diff --git a/Tests/UnitTests/Core/Numeric2/SpecializationTest.h b/Tests/UnitTests/Core/Numeric2/SpecializationTest.h deleted file mode 100644 index d9144e768824cdd91c47db7f8b647939b87eca0b..0000000000000000000000000000000000000000 --- a/Tests/UnitTests/Core/Numeric2/SpecializationTest.h +++ /dev/null @@ -1,92 +0,0 @@ -#include "google_test.h" -#include "Vectors3D.h" -#include "Complex.h" -#include "gtest/internal/gtest-param-util.h" -#include "HardParticles.h" - -const complex_t I(0,1); -double eps_polyh = 7.5e-13; - -using ::testing::Values; -using ::testing::internal::ParamGenerator; -using ::testing::Combine; - -auto qlist = testing::Combine( - testing::Values( - cvector_t({ 1, 0, 0 }), - cvector_t({ 0, 1, 0 }), - cvector_t({ 0, 0, 1 }), - cvector_t({ 1, 1, 0 }), - cvector_t({ 1, 0, 1 }), - cvector_t({ 1, 0, 1 }), - cvector_t({ 1, 1, 1 }) - ), - testing::Values( - cvector_t({ 1, 0, 0 }), - cvector_t({ 0, 1, 0 }), - cvector_t({ 0, 0, 1 }), - cvector_t({ 1, 1, 0 }), - cvector_t({ 1, 0, 1 }), - cvector_t({ 1, 0, 1 }), - cvector_t({ 1, 1, 1 }) - ), - testing::Values( - 1e-19, 1e-17, 1e-15, 1e-13, 1e-11, 1e-9, 1e-7, 1e-5, 1e-4, 1e-3, 1e-2, .1, - 1., 1e1, 1e2, 1e3, 1e4 ), - testing::Values( - -1e-15, +1e-14, -1e-13*I, +1e-12*I, - -1e-11, +1e-10, -1e-9*I, +1e-8*I, - -1e-7, +1e-6, -1e-5*I, +1e-4*I, - -1e-3, +1e-2, -1e-1*I, +1e-1*I, - .9, -.99, .999, -.9999 ) - ); - - -class SpecializationTest : public ::testing::Test -{ -protected: - SpecializationTest() : gen(qlist) {} - ~SpecializationTest(); - - void test_all(IFormFactorBorn* p0, IFormFactorBorn* p1, double eps=1e-12) { - for (auto it : gen) { - cvector_t qdir = std::get<0>(it); - cvector_t qdev = std::get<1>(it); - double qmag = std::get<2>(it); - complex_t qeps = std::get<3>(it); - m_q = qmag * (qdir + qeps*qdev).unit(); - - if (skip_q(1e-99, 5e2)) - continue; - - test_ff_eq(p0, p1, eps_polyh); - } - } - - void test_ff_eq(IFormFactorBorn* p0, IFormFactorBorn* p1, double eps=1e-12) { - complex_t f0 = p0->evaluate_for_q(m_q); - complex_t f1 = p1->evaluate_for_q(m_q); - double avge = (std::abs(f0) + std::abs(f1))/2; - //std::cout<<"q="<<q<<" -> "<<std::setprecision(16)<<" f0="<<f0<<", f1="<<f1<<"\n"; - EXPECT_NEAR( real(f0), real(f1), eps*avge ); - EXPECT_NEAR( imag(f0), imag(f1), eps*avge ); - } - - bool skip_q( double qmag_begin=1e-99, double qmag_end=1e99 ) { - return m_q.mag()<=qmag_begin || m_q.mag()>=qmag_end; - } - - cvector_t m_q; - ParamGenerator<std::tuple<cvector_t, cvector_t, double, complex_t>> gen; -}; - -SpecializationTest::~SpecializationTest() = default; - -TEST_F(SpecializationTest, Start) -{ - double L = 1.5, H = .24, alpha = .6; - FormFactorAnisoPyramid p0(L, L, H, alpha); - FormFactorPyramid p1(L, H, alpha); - test_all(&p0, &p1, eps_polyh); -} - diff --git a/Tests/UnitTests/Core/Numeric2/testlist.h b/Tests/UnitTests/Core/Numeric2/testlist.h deleted file mode 100644 index 7e4055c3006112d40ab4e39a4697f2056d1de61e..0000000000000000000000000000000000000000 --- a/Tests/UnitTests/Core/Numeric2/testlist.h +++ /dev/null @@ -1,3 +0,0 @@ -// To renew this file, run /G/ba/dev-tools/code-tools/update-gtestlist.py <directory> - -#include "SpecializationTest.h" diff --git a/Tests/UnitTests/utilities/qLoopedTest.h b/Tests/UnitTests/utilities/qLoopedTest.h deleted file mode 100644 index 285355e07930cdaa37481607a3700c41676e2947..0000000000000000000000000000000000000000 --- a/Tests/UnitTests/utilities/qLoopedTest.h +++ /dev/null @@ -1,75 +0,0 @@ -// ************************************************************************** // -// -// BornAgain: simulate and fit scattering at grazing incidence -// -//! @file Tests/UnitTests/utilities/qLoopedTest.h -//! @brief Auxiliary utility to loop over q vectors for tests. -//! -//! @homepage http://bornagainproject.org -//! @license GNU General Public License v3 or higher (see COPYING) -//! @copyright Forschungszentrum Jülich GmbH 2016 -//! @authors Scientific Computing Group at MLZ Garching -//! @authors M. Ganeva, G. Pospelov, W. Van Herck, J. Wuttke -// -// ************************************************************************** // - -#ifndef QLOOPEDTEST_H -#define QLOOPEDTEST_H - -#include <tuple> - -const complex_t I(0,1); - -class QLoopedTest: -public ::testing::TestWithParam<std::tuple<cvector_t, cvector_t, double, complex_t>> -{ -protected: - QLoopedTest() {} - virtual void SetUp() - { - cvector_t qdir = std::get<0>(GetParam()); - cvector_t qdev = std::get<1>(GetParam()); - double qmag = std::get<2>(GetParam()); - complex_t qeps = std::get<3>(GetParam()); - q = qmag * (qdir + qeps*qdev).unit(); - } - cvector_t q; - - bool skip_q( double qmag_begin=1e-99, double qmag_end=1e99 ) { - return q.mag()<=qmag_begin || q.mag()>=qmag_end; - } -}; - -auto qlist = testing::Combine( - testing::Values( - cvector_t({ 1, 0, 0 }), - cvector_t({ 0, 1, 0 }), - cvector_t({ 0, 0, 1 }), - cvector_t({ 1, 1, 0 }), - cvector_t({ 1, 0, 1 }), - cvector_t({ 1, 0, 1 }), - cvector_t({ 1, 1, 1 }) - ), - testing::Values( - cvector_t({ 1, 0, 0 }), - cvector_t({ 0, 1, 0 }), - cvector_t({ 0, 0, 1 }), - cvector_t({ 1, 1, 0 }), - cvector_t({ 1, 0, 1 }), - cvector_t({ 1, 0, 1 }), - cvector_t({ 1, 1, 1 }) - ), - testing::Values( - 1e-19, 1e-17, 1e-15, 1e-13, 1e-11, 1e-9, 1e-7, 1e-5, 1e-4, 1e-3, 1e-2, .1, - 1., 1e1, 1e2, 1e3, 1e4 ), - testing::Values( - -1e-15, +1e-14, -1e-13*I, +1e-12*I, - -1e-11, +1e-10, -1e-9*I, +1e-8*I, - -1e-7, +1e-6, -1e-5*I, +1e-4*I, - -1e-3, +1e-2, -1e-1*I, +1e-1*I, - .9, -.99, .999, -.9999 ) - ); - - - -#endif // QLOOPEDTEST_H