DelegatingMatrix implements Matrix<E> { @Override public E get(int row, int col) { final int rowIndex = row + rowOffset; final int colIndex = columnOffset + col; checkIndices(rowIndex, colIndex); return delegate.get(rowIndex, colIndex); } DelegatingMatrix(Matrix<E> delegate, int rowOffset, int columnOffset, int rowCount, int columnCount); @Override int getRows(); @Override int getColumns(); @Override E get(int row, int col); @Override void set(int row, int col, E value); @Override Iterator<MatrixRow<E>> iterator(); @Override String toString();  }
@Test(expectedExceptions = IndexOutOfBoundsException.class, expectedExceptionsMessageRegExp = "Column.*?bounds\\(0,1\\): -1") public void testPartialAccessColumnBelowBounds() throws Exception { new DelegatingMatrix<>(original, 1, 2, 2, 2).get(0, -1); }
@Test(expectedExceptions = IndexOutOfBoundsException.class, expectedExceptionsMessageRegExp = "Row.*?bounds\\(0,1\\): -1") public void testPartialAccessRowBelowBounds() throws Exception { new DelegatingMatrix<>(original, 1, 2, 2, 2).get(-1, 0); }
@Test(expectedExceptions = IndexOutOfBoundsException.class, expectedExceptionsMessageRegExp = "Column.*?bounds\\(0,1\\): 2") public void testPartialAccessColumnAboveBounds() throws Exception { new DelegatingMatrix<>(original, 1, 2, 2, 2).get(0, 2); }
@Test(expectedExceptions = IndexOutOfBoundsException.class, expectedExceptionsMessageRegExp = "Row.*?bounds\\(0,1\\): 2") public void testPartialAccessRowAboveBounds() throws Exception { new DelegatingMatrix<>(original, 1, 2, 2, 2).get(2, 0); }