summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSharang Gupta <sharang@sharanggupta.dev>2026-10-29 02:59:23 +0300
committerGitHub <noreply@github.com>2026-10-29 02:59:23 +0300
commit56b8a9a7b53392097891463023a26c406b422225 (patch)
tree94d089d6dd45c0842e872eaa7fee0506665b2029
parentcdcf24e9e3856feb4ba9836858b36cd219e59ea9 (diff)
downloadzxing-master.tar.xz
Add missing fail() to WriterException tests (#2162)HEADmaster
PDF417EncoderTestCase and EncoderTestCase call methods that must throw WriterException inside try/catch with no fail() after the call, so the tests also pass when nothing is thrown. Removing the throw from checkCharset or appendAlphanumericBytes leaves testCheckCharset, testAppendBytes and testAppendAlphanumericBytes green.
-rw-r--r--core/src/test/java/com/google/zxing/pdf417/encoder/PDF417EncoderTestCase.java4
-rw-r--r--core/src/test/java/com/google/zxing/qrcode/encoder/EncoderTestCase.java2
2 files changed, 6 insertions, 0 deletions
diff --git a/core/src/test/java/com/google/zxing/pdf417/encoder/PDF417EncoderTestCase.java b/core/src/test/java/com/google/zxing/pdf417/encoder/PDF417EncoderTestCase.java
index 6f99c4229..0e9497bf8 100644
--- a/core/src/test/java/com/google/zxing/pdf417/encoder/PDF417EncoderTestCase.java
+++ b/core/src/test/java/com/google/zxing/pdf417/encoder/PDF417EncoderTestCase.java
@@ -71,6 +71,7 @@ public final class PDF417EncoderTestCase extends Assert {
try {
// detect when a TEXT Compaction is applied to a non text input
checkEncodeAutoWithSpecialChars("€ 123,45", Compaction.TEXT);
+ fail("Expected WriterException");
} catch (WriterException e) {
assertNotNull(e.getMessage());
assertTrue(e.getMessage().contains("8364"));
@@ -82,6 +83,7 @@ public final class PDF417EncoderTestCase extends Assert {
// detect when a TEXT Compaction is applied to a non text input
String input = "Hello! " + (char) 128;
checkEncodeAutoWithSpecialChars(input, Compaction.TEXT);
+ fail("Expected WriterException");
} catch (WriterException e) {
assertNotNull(e.getMessage());
assertTrue(e.getMessage().contains("128"));
@@ -101,6 +103,7 @@ public final class PDF417EncoderTestCase extends Assert {
hints.put(EncodeHintType.PDF417_COMPACTION, Compaction.TEXT);
(new MultiFormatWriter()).encode(content, BarcodeFormat.PDF_417, 200, 100, hints);
+ fail("Expected WriterException");
} catch (WriterException e) {
assertNotNull(e.getMessage());
assertTrue(e.getMessage().contains("8364"));
@@ -126,6 +129,7 @@ public final class PDF417EncoderTestCase extends Assert {
try {
// should throw an exception for character 'o' because it exceeds upper limit 110
PDF417HighLevelEncoder.checkCharset(input,110,errorMessage);
+ fail("Expected WriterException");
} catch (WriterException e) {
assertNotNull(e.getMessage());
assertTrue(e.getMessage().contains("111"));
diff --git a/core/src/test/java/com/google/zxing/qrcode/encoder/EncoderTestCase.java b/core/src/test/java/com/google/zxing/qrcode/encoder/EncoderTestCase.java
index b76ef3840..56929aa70 100644
--- a/core/src/test/java/com/google/zxing/qrcode/encoder/EncoderTestCase.java
+++ b/core/src/test/java/com/google/zxing/qrcode/encoder/EncoderTestCase.java
@@ -371,6 +371,7 @@ public final class EncoderTestCase extends Assert {
// Lower letters such as 'a' cannot be encoded in MODE_ALPHANUMERIC.
try {
Encoder.appendBytes("a", Mode.ALPHANUMERIC, bits, Encoder.DEFAULT_BYTE_MODE_ENCODING);
+ fail("Expected WriterException");
} catch (WriterException we) {
// good
}
@@ -570,6 +571,7 @@ public final class EncoderTestCase extends Assert {
// Invalid data.
try {
Encoder.appendAlphanumericBytes("abc", new BitArray());
+ fail("Expected WriterException");
} catch (WriterException we) {
// good
}