1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.geometry.spherical.twod;
18
19 import java.util.stream.Stream;
20
21 import org.apache.commons.geometry.core.precision.DoublePrecisionContext;
22 import org.apache.commons.geometry.core.precision.EpsilonDoublePrecisionContext;
23 import org.junit.Assert;
24 import org.junit.Test;
25
26 public class BoundarySource2STest {
27
28 private static final double TEST_EPS = 1e-10;
29
30 private static final DoublePrecisionContext TEST_PRECISION = new EpsilonDoublePrecisionContext(TEST_EPS);
31
32 @Test
33 public void testToTree() {
34
35 final BoundarySource2S src = () -> Stream.of(
36 GreatCircles.arcFromPoints(Point2S.PLUS_I, Point2S.PLUS_J, TEST_PRECISION));
37
38
39 final RegionBSPTree2S tree = src.toTree();
40
41
42 Assert.assertEquals(3, tree.count());
43 Assert.assertFalse(tree.isFull());
44 Assert.assertFalse(tree.isEmpty());
45 }
46
47 @Test
48 public void testToTree_noBoundaries() {
49
50 final BoundarySource2S src = Stream::empty;
51
52
53 final RegionBSPTree2S tree = src.toTree();
54
55
56 Assert.assertEquals(1, tree.count());
57 Assert.assertFalse(tree.isFull());
58 Assert.assertTrue(tree.isEmpty());
59 }
60 }