LineSegment { public boolean containsSegment(LineSegment other) { return other != null && containsPoint(other.startPoint) && containsPoint(other.endPoint); } LineSegment(Vector startPoint, Vector endPoint); Vector getStartPoint(); Vector getEndPoint(); float getLength(); Rectangle getBoundingRectangle(); LineSegment transformBy(Matrix m); boolean containsSegment(LineSegment other); boolean containsPoint(Vector point);  }
@Test public void containsSegmentNullTest() { LineSegment lineSegment = new LineSegment(new Vector(100.3246f, 769.4974f, 1.0f), new Vector(151.22923f, 769.4974f, 1.0f)); Assert.assertFalse(lineSegment.containsSegment(null)); }
@Test public void containsSegmentTest() { LineSegment lineSegment = new LineSegment(new Vector(100.3246f, 769.4974f, 1.0f), new Vector(151.22923f, 769.4974f, 1.0f)); LineSegment segmentToCheck = new LineSegment(new Vector(110.3246f, 769.4974f, 1.0f), new Vector(140.22923f, 769.4974f, 1.0f)); Assert.assertTrue(lineSegment.containsSegment(segmentToCheck)); }
@Test public void notContainsSegmentTest() { LineSegment lineSegment = new LineSegment(new Vector(120.3246f, 769.4974f, 1.0f), new Vector(151.22923f, 769.4974f, 1.0f)); LineSegment segmentToCheck = new LineSegment(new Vector(110.3246f, 769.4974f, 1.0f), new Vector(115.22923f, 769.4974f, 1.0f)); Assert.assertFalse(lineSegment.containsSegment(segmentToCheck)); }