Convert asserts to exceptions where the conditions could be false in a correct, bug...
authorsrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Thu, 5 Feb 2009 13:06:19 +0000 (13:06 +0000)
committersrowen <srowen@59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Thu, 5 Feb 2009 13:06:19 +0000 (13:06 +0000)
git-svn-id: http://zxing.googlecode.com/svn/trunk@840 59b500cc-1b3d-0410-9834-0bbf25fbcc57

android/src/com/google/zxing/client/android/YUVMonochromeBitmapSource.java
androidtest/src/com/google/zxing/client/androidtest/BenchmarkItem.java
androidtest/src/com/google/zxing/client/androidtest/SaveThread.java

index cda9929..a45fda6 100755 (executable)
@@ -40,11 +40,12 @@ final class YUVMonochromeBitmapSource extends BaseMonochromeBitmapSource {
    * @param crop       The rectangle within the yuvData to expose to MonochromeBitmapSource users
    */
   YUVMonochromeBitmapSource(byte[] yuvData, int dataWidth, int dataHeight, Rect crop) {
+    if (crop.width() > dataWidth || crop.height() > dataHeight) {
+      throw new IllegalArgumentException();
+    }
     mYUVData = yuvData;
     mDataWidth = dataWidth;
     mCrop = crop;
-    assert (crop.width() <= dataWidth);
-    assert (crop.height() <= dataHeight);
   }
 
   @Override
index 4cb418c..e334ca0 100644 (file)
@@ -27,8 +27,10 @@ public final class BenchmarkItem {
   private BarcodeFormat mFormat;
 
   public BenchmarkItem(String path, int runs) {
+    if (runs <= 0) {
+      throw new IllegalArgumentException();
+    }
     mPath = path;
-    assert(runs > 0);
     mTimes = new int[runs];
     mPosition = 0;
     mDecoded = false;
index 1692858..698d6ef 100755 (executable)
@@ -67,8 +67,9 @@ final class SaveThread extends Thread {
   private void save(byte[] data, int width, int height) {
     int framingWidth = mFramingRect.width();
     int framingHeight = mFramingRect.height();
-    assert (framingWidth <= width);
-    assert (framingHeight <= height);
+    if (framingWidth > width || framingHeight > height) {
+      throw new IllegalArgumentException();
+    }
 
     int leftOffset = mFramingRect.left;
     int topOffset = mFramingRect.top;