Viewport { public Viewport set(int x, int y, int width, int height) { this.x = x; this.y = y; this.width = width; this.height = height; return this; } Viewport();  Viewport(int x, int y, int width, int height);  Viewport(Viewport viewport); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); Viewport set(int x, int y, int width, int height); Viewport set(Viewport viewport); Viewport setEmpty(); boolean isEmpty(); boolean intersects(int x, int y, int width, int height); @SuppressWarnings("UnnecessaryLocalVariable") boolean intersects(Viewport viewport); boolean intersect(int x, int y, int width, int height); @SuppressWarnings("UnnecessaryLocalVariable") boolean intersect(Viewport viewport); boolean contains(int x, int y); public int x; public int y; public int width; public int height; }
@Test public void testSet_Parameters() throws Exception { Viewport viewport = new Viewport(); viewport.set(1, 2, 3, 4); assertEquals("x", 1, viewport.x); assertEquals("y", 2, viewport.y); assertEquals("width", 3, viewport.width); assertEquals("height", 4, viewport.height); }
@Test public void testSet_Copy() throws Exception { Viewport original = new Viewport(1, 2, 3, 4); Viewport viewport = new Viewport(); viewport.set(original); assertTrue("not the same reference", original != viewport); assertEquals("x", 1, viewport.x); assertEquals("y", 2, viewport.y); assertEquals("width", 3, viewport.width); assertEquals("height", 4, viewport.height); }