View Javadoc

    1   /*
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements.  See the NOTICE file distributed with
    4    * this work for additional information regarding copyright ownership.
    5    * The ASF licenses this file to You under the Apache License, Version 2.0
    6    * (the "License"); you may not use this file except in compliance with
    7    * the License.  You may obtain a copy of the License at
    8    *
    9    *      http://www.apache.org/licenses/LICENSE-2.0
    10   *
    11   * Unless required by applicable law or agreed to in writing, software
    12   * distributed under the License is distributed on an "AS IS" BASIS,
    13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14   * See the License for the specific language governing permissions and
    15   * limitations under the License.
    16   */
    17  package org.apache.commons.geometry.euclidean.threed;
    18
    19  import java.util.Collections;
    20  import java.util.List;
    21
    22  import org.apache.commons.numbers.core.Precision;
    23  import org.junit.jupiter.api.Assertions;
    24  import org.junit.jupiter.api.Test;
    25
    26  class BoundaryList3DTest {
    27
    28      private static final double TEST_EPS = 1e-10;
    29
    30      private static final Precision.DoubleEquivalence TEST_PRECISION =
    31              Precision.doubleEquivalenceOfEpsilon(TEST_EPS);
    32
    33      @Test
    34      void testCtor() {
    35          // arrange
    36          final List<PlaneConvexSubset> boundaries = Collections.singletonList(
    37                  Planes.fromNormal(Vector3D.Unit.PLUS_X, TEST_PRECISION).span()
    38          );
    39
    40          // act
    41          final BoundaryList3D list = new BoundaryList3D(boundaries);
    42
    43          // assert
    44          Assertions.assertNotSame(boundaries, list.getBoundaries());
    45          Assertions.assertEquals(boundaries, list.getBoundaries());
    46          Assertions.assertEquals(1, list.count());
    47      }
    48
    49      @Test
    50      void testToList() {
    51          // arrange
    52          final BoundaryList3D list = new BoundaryList3D(Collections.emptyList());
    53
    54          // act/assert
    55          Assertions.assertSame(list, list.toList());
    56      }
    57
    58      @Test
    59      void testToString() {
    60          // arrange
    61          final BoundaryList3D list = new BoundaryList3D(Collections.emptyList());
    62
    63          // act
    64          Assertions.assertEquals("BoundaryList3D[count= 0]", list.toString());
    65      }
    66  }