### Question:
LineUtils { public static List<Integer> bresenham(int x0, int y0, int x1, int y1) { List<Integer> list = new ArrayList<>(Math.max(Math.abs(x1 - x0), Math.abs(y1 - y0))); int d = 0; int dx = Math.abs(x1 - x0); int dy = Math.abs(y1 - y0); int dx2 = 2 * dx; int dy2 = 2 * dy; int ix = x0 < x1 ? 1 : -1; int iy = y0 < y1 ? 1 : -1; int x = x0; int y = y0; if (dx >= dy) { while (true) { list.add(x); list.add(y); if (x == x1) break; x += ix; d += dy2; if (d > dx) { y += iy; d -= dx2; } } } else { while (true) { list.add(x); list.add(y); if (y == y1) break; y += iy; d += dx2; if (d > dy) { x += ix; d -= dy2; } } } return list; }  static List<Integer> bresenham(int x0, int y0, int x1, int y1);  }### Answer:
@Test public void testBresenham2D_AlongPositiveX() { List<Integer> points = LineUtils.bresenham(0, 0, 4, 0); assertEquals(10, points.size()); assertEquals(0, points.get(0).intValue()); assertEquals(1, points.get(2).intValue()); assertEquals(2, points.get(4).intValue()); assertEquals(3, points.get(6).intValue()); assertEquals(4, points.get(8).intValue()); }
@Test public void testBresenham2D_AlongPositiveY() { List<Integer> points = LineUtils.bresenham(0, 0, 0, 4); assertEquals(10, points.size()); assertEquals(0, points.get(1).intValue()); assertEquals(1, points.get(3).intValue()); assertEquals(2, points.get(5).intValue()); assertEquals(3, points.get(7).intValue()); assertEquals(4, points.get(9).intValue()); }