PDF417BlackBox4TestCase.java (zxing-zxing-3.4.0) | : | PDF417BlackBox4TestCase.java (zxing-zxing-3.4.1) | ||
---|---|---|---|---|
skipping to change at line 72 | skipping to change at line 72 | |||
private final List<TestResult> testResults = new ArrayList<>(); | private final List<TestResult> testResults = new ArrayList<>(); | |||
public PDF417BlackBox4TestCase() { | public PDF417BlackBox4TestCase() { | |||
super("src/test/resources/blackbox/pdf417-4", null, BarcodeFormat.PDF_417); | super("src/test/resources/blackbox/pdf417-4", null, BarcodeFormat.PDF_417); | |||
testResults.add(new TestResult(3, 3, 0, 0, 0.0f)); | testResults.add(new TestResult(3, 3, 0, 0, 0.0f)); | |||
} | } | |||
@Test | @Test | |||
@Override | @Override | |||
public void testBlackBox() throws IOException { | public void testBlackBox() throws IOException { | |||
testPDF417BlackBoxCountingResults(true); | ||||
} | ||||
private void testPDF417BlackBoxCountingResults(boolean assertOnFailure) throws | ||||
IOException { | ||||
assertFalse(testResults.isEmpty()); | assertFalse(testResults.isEmpty()); | |||
Map<String,List<Path>> imageFiles = getImageFileLists(); | Map<String,List<Path>> imageFiles = getImageFileLists(); | |||
int testCount = testResults.size(); | int testCount = testResults.size(); | |||
int[] passedCounts = new int[testCount]; | int[] passedCounts = new int[testCount]; | |||
int[] tryHarderCounts = new int[testCount]; | int[] tryHarderCounts = new int[testCount]; | |||
Path testBase = getTestBase(); | Path testBase = getTestBase(); | |||
skipping to change at line 160 | skipping to change at line 156 | |||
log.info(String.format("Decoded %d images out of %d (%d%%, %d required)", to talFound, totalTests, totalFound * | log.info(String.format("Decoded %d images out of %d (%d%%, %d required)", to talFound, totalTests, totalFound * | |||
100 / | 100 / | |||
totalTests, totalMustPass)); | totalTests, totalMustPass)); | |||
if (totalFound > totalMustPass) { | if (totalFound > totalMustPass) { | |||
log.warning(String.format("+++ Test too lax by %d images", totalFound - to talMustPass)); | log.warning(String.format("+++ Test too lax by %d images", totalFound - to talMustPass)); | |||
} else if (totalFound < totalMustPass) { | } else if (totalFound < totalMustPass) { | |||
log.warning(String.format("--- Test failed by %d images", totalMustPass - totalFound)); | log.warning(String.format("--- Test failed by %d images", totalMustPass - totalFound)); | |||
} | } | |||
// Then run through again and assert if any failed | // Then run through again and assert if any failed | |||
if (assertOnFailure) { | for (int x = 0; x < testCount; x++) { | |||
for (int x = 0; x < testCount; x++) { | TestResult testResult = testResults.get(x); | |||
TestResult testResult = testResults.get(x); | String label = "Rotation " + testResult.getRotation() + " degrees: Too man | |||
String label = "Rotation " + testResult.getRotation() + " degrees: Too m | y images failed"; | |||
any images failed"; | assertTrue(label, passedCounts[x] >= testResult.getMustPassCount()); | |||
assertTrue(label, passedCounts[x] >= testResult.getMustPassCount()); | assertTrue("Try harder, " + label, tryHarderCounts[x] >= testResult.getTry | |||
assertTrue("Try harder, " + label, tryHarderCounts[x] >= testResult.getT | HarderCount()); | |||
ryHarderCount()); | ||||
} | ||||
} | } | |||
} | } | |||
private static PDF417ResultMetadata getMeta(Result result) { | private static PDF417ResultMetadata getMeta(Result result) { | |||
return result.getResultMetadata() == null ? null : (PDF417ResultMetadata) re sult.getResultMetadata().get( | return result.getResultMetadata() == null ? null : (PDF417ResultMetadata) re sult.getResultMetadata().get( | |||
ResultMetadataType.PDF417_EXTRA_METADATA); | ResultMetadataType.PDF417_EXTRA_METADATA); | |||
} | } | |||
private Result[] decode(BinaryBitmap source, boolean tryHarder) throws ReaderE xception { | private Result[] decode(BinaryBitmap source, boolean tryHarder) throws ReaderE xception { | |||
Map<DecodeHintType,Object> hints = new EnumMap<>(DecodeHintType.class); | Map<DecodeHintType,Object> hints = new EnumMap<>(DecodeHintType.class); | |||
End of changes. 2 change blocks. | ||||
14 lines changed or deleted | 7 lines changed or added |