Skip to content
Snippets Groups Projects
Unverified Commit e62db937 authored by Sam Yates's avatar Sam Yates Committed by GitHub
Browse files

Add unit test for 0-length segment area. (#1291)

* Add unit test that checks the expected contribution of an
annulus to the embed_pwlin integrated area, when a zero-length segment
with differing radii exists in the segment tree.
parent d326f2ea
No related branches found
No related tags found
No related merge requests found
......@@ -216,3 +216,31 @@ TEST(embedding, partial_area) {
double expected_ixa = 3/(9.5*8)/pi;
EXPECT_TRUE(near_relative(expected_ixa, em.integrate_ixa(mcable{1, 0.1, 0.4}), reltol));
}
TEST(embedding, area_0_length_segment) {
using testing::near_relative;
constexpr double pi = math::pi<double>;
constexpr double reltol = 1e-10;
segment_tree t1, t2;
t1.append(mnpos, { 0, 0, 0, 10}, {10, 0, 0, 10}, 0);
t1.append(0, {10, 0, 0, 20}, {30, 0, 0, 20}, 0);
t2.append(mnpos, { 0, 0, 0, 10}, {10, 0, 0, 10}, 0);
t2.append(0, {10, 0, 0, 10}, {10, 0, 0, 20}, 0);
t2.append(1, {10, 0, 0, 20}, {30, 0, 0, 20}, 0);
embedding em1{morphology(t1)}, em2{morphology(t2)};
double a1 = em1.integrate_area(mcable{0, 0, 1});
double expected_a1 = 2*pi*(10*10+20*20);
EXPECT_TRUE(near_relative(a1, expected_a1, reltol));
// The second morphology includes the anulus joining the
// first and last segment.
double a2 = em2.integrate_area(mcable{0, 0, 1});
double expected_a2 = expected_a1 + pi*(20*20-10*10);
EXPECT_TRUE(near_relative(a2, expected_a2, reltol));
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment