Skip to content

Commit 1d17ae9

Browse files
committed
DataMatrix. Add test with zero textSize
DEVSIX-1845
1 parent 2da3c49 commit 1d17ae9

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

barcodes/src/main/java/com/itextpdf/barcodes/BarcodeDataMatrix.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ public int setCode(byte[] text, int textOffset, int textSize) {
342342
if (textOffset < 0) {
343343
throw new IndexOutOfBoundsException("" + textOffset);
344344
}
345-
if (textOffset + textSize > text.length || textOffset + textSize < 0) {
345+
if (textOffset + textSize > text.length || textSize < 0) {
346346
throw new IndexOutOfBoundsException("" + textSize);
347347
}
348348
int extCount, e, k, full;

barcodes/src/test/java/com/itextpdf/barcodes/BarcodeDataMatrixTest.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -232,10 +232,9 @@ public void barcode11Test() {
232232
Assert.assertEquals(BarcodeDataMatrix.DM_NO_ERROR, result);
233233
}
234234

235-
236235
@Test
237236
public void barcode12Test() {
238-
junitExpectedException.expect(IndexOutOfBoundsException.class);;
237+
junitExpectedException.expect(IndexOutOfBoundsException.class);
239238
BarcodeDataMatrix barcodeDataMatrix = new BarcodeDataMatrix();
240239
barcodeDataMatrix.setWidth(18);
241240
barcodeDataMatrix.setHeight(18);
@@ -245,7 +244,7 @@ public void barcode12Test() {
245244

246245
@Test
247246
public void barcode13Test() {
248-
junitExpectedException.expect(IndexOutOfBoundsException.class);;
247+
junitExpectedException.expect(IndexOutOfBoundsException.class);
249248
BarcodeDataMatrix barcodeDataMatrix = new BarcodeDataMatrix();
250249
barcodeDataMatrix.setWidth(18);
251250
barcodeDataMatrix.setHeight(18);
@@ -255,11 +254,21 @@ public void barcode13Test() {
255254

256255
@Test
257256
public void barcode14Test() {
258-
junitExpectedException.expect(IndexOutOfBoundsException.class);;
257+
junitExpectedException.expect(IndexOutOfBoundsException.class);
259258
BarcodeDataMatrix barcodeDataMatrix = new BarcodeDataMatrix();
260259
barcodeDataMatrix.setWidth(18);
261260
barcodeDataMatrix.setHeight(18);
262261
byte[] str = "AbcdFFghijklmnop".getBytes();
263262
barcodeDataMatrix.setCode(str, 0, -1);
264263
}
264+
265+
@Test
266+
public void barcode15Test() {
267+
BarcodeDataMatrix barcodeDataMatrix = new BarcodeDataMatrix();
268+
barcodeDataMatrix.setWidth(18);
269+
barcodeDataMatrix.setHeight(18);
270+
byte[] str = "AbcdFFghijklmnop".getBytes();
271+
int result = barcodeDataMatrix.setCode(str, str.length, 0);
272+
Assert.assertEquals(BarcodeDataMatrix.DM_NO_ERROR, result);
273+
}
265274
}

0 commit comments

Comments
 (0)