Elleptic_integralsTest.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #include <gtest/gtest.h>
  2. #include "modules/Elliptic_integrals.cpp"
  3. #include <cmath>
  4. class Elliptic_IntegralsTest : public testing::Test{};
  5. TEST_F(Elliptic_IntegralsTest, Elliptic_0_0)
  6. {
  7. std::vector<double> res = Elliptic(0, 0);
  8. EXPECT_DOUBLE_EQ(res[0], 0) << "F(0, 0)";
  9. EXPECT_DOUBLE_EQ(res[1], 0) << "E(0, 0)";
  10. }
  11. TEST_F(Elliptic_IntegralsTest, Elliptic_90_0)
  12. {
  13. std::vector<double> res = Elliptic(90, 0);
  14. EXPECT_DOUBLE_EQ(res[0], M_PI / 2) << "F(90, 0)";
  15. EXPECT_DOUBLE_EQ(res[1], M_PI / 2)<< "E(90, 0)";
  16. }
  17. TEST_F(Elliptic_IntegralsTest, Elliptic_0_1)
  18. {
  19. std::vector<double> res = Elliptic(0, 1);
  20. EXPECT_DOUBLE_EQ(res[0], 0) << "F(0, 1)";
  21. EXPECT_DOUBLE_EQ(res[1], 0) << "E(0, 1)";
  22. }
  23. TEST_F(Elliptic_IntegralsTest, Elliptic_90_1)
  24. {
  25. std::vector<double> res = Elliptic(90, 1);
  26. EXPECT_DOUBLE_EQ(res[0], std::numeric_limits<double>::infinity()) << "F(90, 1)";
  27. EXPECT_DOUBLE_EQ(res[1], 1)<< "E(90, 1)";
  28. }
  29. TEST_F(Elliptic_IntegralsTest, Elliptic_Throw)
  30. {
  31. std::vector<double> result = Elliptic(50, 2);
  32. EXPECT_EQ(result.size(), 0); // if k > 1 or k < - 1 vector of Elliptic(phi, k) should be empty
  33. }
  34. int main(int argc, char **argv)
  35. {
  36. testing::InitGoogleTest(&argc, argv);
  37. return RUN_ALL_TESTS();
  38. }