package com.thealgorithms.geometry; import java.awt.Point; import java.util.Collection; import java.util.List; import java.util.stream.Stream; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; /** * The {@code BresenhamLineTest} class contains unit tests for the * {@code BresenhamLine} class, specifically testing the * {@code findLine} method. * *
This class uses parameterized tests to validate the output of * Bresenham's line algorithm for various input points.
*/ class BresenhamLineTest { /** * Provides test cases for the parameterized test. * *Each test case includes starting coordinates, ending coordinates, * and the expected collection of points that should be generated by the * {@code findLine} method.
* * @return a stream of arguments containing test cases */ static StreamThis parameterized test runs multiple times with different sets of * starting and ending coordinates to validate that the generated points * match the expected output.
* * @param x0 the x-coordinate of the starting point * @param y0 the y-coordinate of the starting point * @param x1 the x-coordinate of the ending point * @param y1 the y-coordinate of the ending point * @param expected a collection of expected points that should form a line */ @ParameterizedTest @MethodSource("linePointsProvider") void testFindLine(int x0, int y0, int x1, int y1, Collection