Elleptic_integralsTest.cpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #include <gtest/gtest.h>
  2. #include "modules/Elliptic_integrals.cpp"
  3. #include <cmath>
  4. class Elliptic_IntegralsTest : public testing::Test {
  5. protected:
  6. Elliptic_IntegralsTest()
  7. {
  8. }
  9. ~Elliptic_IntegralsTest() override
  10. {
  11. }
  12. void SetUp() override
  13. {
  14. }
  15. void TearDown() override
  16. {
  17. }
  18. };
  19. TEST_F(Elliptic_IntegralsTest, Elliptic_0_0)
  20. {
  21. Elliptic_Integrals ElInt;
  22. std::vector<double> res = ElInt.Elliptic(0, 0);
  23. EXPECT_DOUBLE_EQ(res[0], 0) << "F(0, 0)";
  24. EXPECT_DOUBLE_EQ(res[1], 0) << "E(0, 0)";
  25. }
  26. TEST_F(Elliptic_IntegralsTest, Elliptic_90_0)
  27. {
  28. Elliptic_Integrals ElInt;
  29. std::vector<double> res = ElInt.Elliptic(90, 0);
  30. EXPECT_DOUBLE_EQ(res[0], M_PI / 2) << "F(90, 0)";
  31. EXPECT_DOUBLE_EQ(res[1], M_PI / 2)<< "E(90, 0)";
  32. }
  33. TEST_F(Elliptic_IntegralsTest, Elliptic_0_1)
  34. {
  35. Elliptic_Integrals ElInt;
  36. std::vector<double> res = ElInt.Elliptic(0, 1);
  37. EXPECT_DOUBLE_EQ(res[0], 0) << "F(0, 1)";
  38. EXPECT_DOUBLE_EQ(res[1], 0) << "E(0, 1)";
  39. }
  40. TEST_F(Elliptic_IntegralsTest, Elliptic_90_1)
  41. {
  42. Elliptic_Integrals ElInt;
  43. std::vector<double> res = ElInt.Elliptic(90, 1);
  44. EXPECT_DOUBLE_EQ(res[0], std::numeric_limits<double>::infinity()) << "F(90, 1)";
  45. EXPECT_DOUBLE_EQ(res[1], 1)<< "E(90, 1)";
  46. }
  47. TEST_F(Elliptic_IntegralsTest, Elliptic_Throw)
  48. {
  49. Elliptic_Integrals ellIntegrals;
  50. std::vector<double> result = ellIntegrals.Elliptic(50, 2);
  51. EXPECT_EQ(result.size(), 0); // if k > 1 or k < - 1 vector of Elliptic(phi, k) should be empty
  52. }
  53. int main(int argc, char **argv)
  54. {
  55. testing::InitGoogleTest(&argc, argv);
  56. return RUN_ALL_TESTS();
  57. }