/** * Checks if the given values are equal. If not, an <code>IllegalArgumentException</code> is thrown with a * standardized message text using the supplied message. * <p/> * <p>This utility method is used to check arguments passed into methods: * <pre> * public void writeDataAtRegion(int x, inty, int w, int h, byte[] data) { * Guardian.assertEquals("data.length", * data.length, w * h); * ... * } * </pre> * * @param exprText the test expression as text * @param exprValue the test expression result * @param expectedValue the expected value * @throws IllegalArgumentException if the <code>exprValue</code> is not equal to <code>expectedValue</code> */ public static void assertEquals(String exprText, boolean exprValue, boolean expectedValue) { assertEquals(exprText, Boolean.valueOf(exprValue), Boolean.valueOf(expectedValue)); }
private void checkBufferSize(int sourceWidth, int sourceHeight, ProductData sourceBuffer) { int expectedBufferSize = sourceWidth * sourceHeight; int actualBufferSize = sourceBuffer.getNumElems(); Guardian.assertEquals("wrong sourceBuffer size", actualBufferSize, expectedBufferSize); }
private static void checkBufferSize(int sourceWidth, int sourceHeight, ProductData sourceBuffer) { final int expectedBufferSize = sourceWidth * sourceHeight; final int actualBufferSize = sourceBuffer.getNumElems(); Guardian.assertEquals("sourceWidth * sourceHeight", actualBufferSize, expectedBufferSize); /*I18N*/ }
/** * Sets a valid-mask for the given ID. * * @param id the ID * @param validMask the pixel mask * * @see #createValidMask(String, com.bc.ceres.core.ProgressMonitor) * @deprecated since BEAM 4.7, use {@link #getMaskGroup()} instead */ @Deprecated public void setValidMask(final String id, final BitRaster validMask) { if (validMask != null) { Guardian.assertEquals("validMask", validMask.getWidth(), getSceneRasterWidth()); Guardian.assertEquals("validMask", validMask.getHeight(), getSceneRasterHeight()); if (validMasks == null) { validMasks = new HashMap<>(); } validMasks.put(id, validMask); } else { if (validMasks != null) { validMasks.remove(id); } } }
public void testAssertEquals_int() { int expected; int actual; try { expected = 3; actual = 3; Guardian.assertEquals("message", actual, expected); } catch (IllegalArgumentException e) { fail("IllegalArgumentException not actual"); } try { actual = 4; expected = 3; Guardian.assertEquals("actual", actual, expected); fail("IllegalArgumentException actual"); } catch (IllegalArgumentException e) { testException(e, "[actual] is [4] but should be equal to [3]"); } try { actual = 3; expected = 4; Guardian.assertEquals("actual", actual, expected); fail("IllegalArgumentException actual"); } catch (IllegalArgumentException e) { testException(e, "[actual] is [3] but should be equal to [4]"); } }
private void checkGeoCoding(final GeoCoding geoCoding) { if (geoCoding instanceof TiePointGeoCoding) { final TiePointGeoCoding gc = (TiePointGeoCoding) geoCoding; Guardian.assertSame("gc.getLatGrid()", gc.getLatGrid(), getTiePointGrid(gc.getLatGrid().getName())); Guardian.assertSame("gc.getLonGrid()", gc.getLonGrid(), getTiePointGrid(gc.getLonGrid().getName())); } else if (geoCoding instanceof MapGeoCoding) { final MapGeoCoding gc = (MapGeoCoding) geoCoding; final MapInfo mapInfo = gc.getMapInfo(); Guardian.assertNotNull("mapInfo", mapInfo); Guardian.assertEquals("mapInfo.getSceneWidth()", mapInfo.getSceneWidth(), getSceneRasterWidth()); Guardian.assertEquals("mapInfo.getSceneHeight()", mapInfo.getSceneHeight(), getSceneRasterHeight()); } }
final Rectangle destArea) { Guardian.assertNotNull("sourceGeoCoding", sourceGeoCoding); Guardian.assertEquals("sourceGeoCoding.canGetPixelPos()", sourceGeoCoding.canGetPixelPos(), true); Guardian.assertNotNull("destGeoCoding", destGeoCoding); Guardian.assertEquals("destGeoCoding.canGetGeoPos()", destGeoCoding.canGetGeoPos(), true); Guardian.assertNotNull("destArea", destArea);