Package h07.graph

Class PathImplTest

    • Constructor Detail

      • PathImplTest

        public PathImplTest()
    • Method Detail

      • testDefinition

        @Test
        public void testDefinition()
        Tests the definition of PathImpl.
        • Asserts that the class...
          • is package-private
          • is not abstract
          • is generic and has the type parameters V and A
          • either extends AbstractPath or implements Path directly
        Specified by:
        testDefinition in class TestClass
      • testConcat

        @ParameterizedTest
        @ArgumentsSource(PathProvider.class)
        public void testConcat​(Character[] nodes,
                               int[] arcWeights)
                        throws ReflectiveOperationException
        Tests for PathImpl.concat(Object, Object). Requires PathImpl.traverser().
        Asserts that the object returned by the tested method is a new PathImpl object. Further asserts that the order and weights of nodes didn't change and the new node was appended to the end. Also asserts that the method throws a NullPointerException if invoked with null.
        Parameters:
        nodes - an array of nodes (supplied by the arguments provider)
        arcWeights - an array of weights from a node at index i to the one at index i + 1 (supplied by the arguments provider)
        Throws:
        ReflectiveOperationException - if any invocation fails
      • newInstance

        public Object newInstance​(Object... params)
        Returns a new PathImpl object.
        It is necessary to override TestClass.newInstance(Object...) because no constructors have been specified by the assignment, so using Path.of(V), Path.of(V, A, V) or Path.of(V, A, V, A, V) is the way to go.
        Overrides:
        newInstance in class TestClass
        Parameters:
        params - the parameters to supply to the constructor, either 1, 3 or 5 parameters as specified by the static initializer methods of Path
        Returns:
        a new PathImpl instance