mirror of
https://github.com/zxing/zxing.git
synced 2024-11-10 04:54:04 -08:00
Convert asserts to exceptions where the conditions could be false in a correct, bug-free program -- makes sure caller errors are caught and reported meaningfully
git-svn-id: https://zxing.googlecode.com/svn/trunk@840 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
07db37e997
commit
1c539c66a4
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue