12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- #include <gtest/gtest.h>
- #include "modules/Elliptic_integrals.cpp"
- #include <cmath>
- class Elliptic_IntegralsTest : public testing::Test {
- protected:
- Elliptic_IntegralsTest()
- {
- }
- ~Elliptic_IntegralsTest() override
- {
- }
- void SetUp() override
- {
- }
- void TearDown() override
- {
- }
- };
- TEST_F(Elliptic_IntegralsTest, Elliptic_0_0)
- {
- Elliptic_Integrals ElInt;
- std::vector<double> res = ElInt.Elliptic(0, 0);
- EXPECT_DOUBLE_EQ(res[0], 0) << "F(0, 0)";
- EXPECT_DOUBLE_EQ(res[1], 0) << "E(0, 0)";
- }
- TEST_F(Elliptic_IntegralsTest, Elliptic_90_0)
- {
- Elliptic_Integrals ElInt;
- std::vector<double> res = ElInt.Elliptic(90, 0);
- EXPECT_DOUBLE_EQ(res[0], M_PI / 2) << "F(90, 0)";
- EXPECT_DOUBLE_EQ(res[1], M_PI / 2)<< "E(90, 0)";
- }
- TEST_F(Elliptic_IntegralsTest, Elliptic_0_1)
- {
- Elliptic_Integrals ElInt;
- std::vector<double> res = ElInt.Elliptic(0, 1);
- EXPECT_DOUBLE_EQ(res[0], 0) << "F(0, 1)";
- EXPECT_DOUBLE_EQ(res[1], 0) << "E(0, 1)";
- }
- TEST_F(Elliptic_IntegralsTest, Elliptic_90_1)
- {
- Elliptic_Integrals ElInt;
- std::vector<double> res = ElInt.Elliptic(90, 1);
- EXPECT_DOUBLE_EQ(res[0], std::numeric_limits<double>::infinity()) << "F(90, 1)";
- EXPECT_DOUBLE_EQ(res[1], 1)<< "E(90, 1)";
- }
- TEST_F(Elliptic_IntegralsTest, Elliptic_Throw)
- {
- Elliptic_Integrals ellIntegrals;
- std::vector<double> result = ellIntegrals.Elliptic(50, 2);
- EXPECT_EQ(result.size(), 0); // if k > 1 or k < - 1 vector of Elliptic(phi, k) should be empty
- }
- int main(int argc, char **argv)
- {
- testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
- }
|