#include "Sample/HardParticle/HardParticles.h"

#include "Sample/Particle/Rotations.h"
#include "Tests/Unit/Numeric/MultiQTest.h"
#include <numbers>

using std::numbers::pi;

TEST(FormfactorOtherTest, HorizontalCylinderAsCylinder)
{
    const double R = .3, L = 3;
    Cylinder f0(R, L);
    HorizontalCylinder f1(R, L);

    int failures = formfactorTest::run_test_for_many_q(
        [&](C3 q) -> complex_t { return f0.formfactorAtBottom(q); },
        [&](C3 q) -> complex_t { return f1.formfactorAtBottom(q.rotatedY(pi / 2)); }, 1e-99, 100,
        2e-15, true);
    EXPECT_EQ(failures, 0);
}

TEST(FormfactorOtherTest, HorizontalCylinderSlices)
{
    const double R = .3, L = 3;
    HorizontalCylinder f0(R, L);
    HorizontalCylinder f1a(R, L, 1.3 * R, 0);
    HorizontalCylinder f1b(R, L, 0, 0.7 * R);

    int failures = formfactorTest::run_test_for_many_q(
        [&](C3 q) -> complex_t { return f0.formfactorAtBottom(q); },
        [&](C3 q) -> complex_t {
            return f1a.formfactorAtBottom(q) + exp_I(q.z() * 0.7 * R) * f1b.formfactorAtBottom(q);
        },
        1e-99, 100, 1.2e-12, true);
    EXPECT_EQ(failures, 0);
}
