Skip to content

Commit b8ac8aa

Browse files
Add unit tests for the bug in gh-46.
1 parent e51f130 commit b8ac8aa

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

tests/xsf_tests/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
These tests are independent of SciPy.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include "../testing_utils.h"
2+
3+
#include <complex>
4+
#include <tuple>
5+
#include <xsf/bessel.h>
6+
7+
8+
TEST_CASE("cyl_bessel_k gh-46", "[cyl_bessel_k][xsf_tests]") {
9+
using test_case = std::tuple<double, std::complex<double>, std::complex<double>, double>;
10+
auto [v, z, ref, rtol] = GENERATE(
11+
test_case{0.0, std::complex{680.0, -1000.0},
12+
std::complex{1.901684871999608e-298, 1.713412341479591e-297}, 1e-13},
13+
test_case{0.0, std::complex{680.0, -680.0},
14+
std::complex{-4.553730032944803e-298, 1.878727010109855e-297}, 1e-13},
15+
test_case(0.0, std::complex{25.0, 100.0},
16+
std::complex{1.699267100365868e-12, -2.234890030902166e-13}, 5e-16)
17+
);
18+
const std::complex w = xsf::cyl_bessel_k(v, z);
19+
const auto rel_error = xsf::extended_relative_error(w, ref);
20+
21+
CAPTURE(v, z, w, ref, rtol, rel_error);
22+
REQUIRE(rel_error <= rtol);
23+
}

0 commit comments

Comments
 (0)