mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 04:12:34 +00:00
Add error reporting to tests
This commit is contained in:
@@ -25,7 +25,12 @@ use std::{
|
||||
};
|
||||
|
||||
use encoding::Encoding;
|
||||
use rxing::{common::{HybridBinarizer, Result}, pdf417::PDF417RXingResultMetadata, BarcodeFormat, BinaryBitmap, BufferedImageLuminanceSource, DecodeHintType, DecodeHintValue, RXingResultMetadataType, RXingResultMetadataValue, Reader, Binarizer};
|
||||
use rxing::{
|
||||
common::{HybridBinarizer, Result},
|
||||
pdf417::PDF417RXingResultMetadata,
|
||||
BarcodeFormat, Binarizer, BinaryBitmap, BufferedImageLuminanceSource, DecodeHintType,
|
||||
DecodeHintValue, RXingResultMetadataType, RXingResultMetadataValue, Reader,
|
||||
};
|
||||
|
||||
use super::TestRXingResult;
|
||||
|
||||
@@ -254,21 +259,23 @@ impl<T: Reader> AbstractBlackBoxTestCase<T> {
|
||||
// drop(f);
|
||||
// Self::rotate_image(&image, rotation).save("test_image.png").unwrap();
|
||||
// }
|
||||
|
||||
if let Ok(decoded) = self.decode(
|
||||
match self.decode(
|
||||
&mut bitmap,
|
||||
rotation,
|
||||
&expected_text,
|
||||
&expected_metadata,
|
||||
false,
|
||||
) {
|
||||
if decoded {
|
||||
passed_counts[x] += 1;
|
||||
} else {
|
||||
misread_counts[x] += 1;
|
||||
Ok(decoded) => {
|
||||
if decoded {
|
||||
passed_counts[x] += 1;
|
||||
} else {
|
||||
misread_counts[x] += 1;
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
log::fine(format!("could not read at rotation {rotation}: {e:?}"));
|
||||
}
|
||||
} else {
|
||||
log::fine(format!("could not read at rotation {rotation}"));
|
||||
}
|
||||
// try {
|
||||
// if (decode(bitmap, rotation, expectedText, expectedMetadata, false)) {
|
||||
@@ -279,20 +286,23 @@ impl<T: Reader> AbstractBlackBoxTestCase<T> {
|
||||
// } catch (ReaderException ignored) {
|
||||
// log::fine(format!("could not read at rotation {}", rotation));
|
||||
// }
|
||||
if let Ok(decoded) = self.decode(
|
||||
match self.decode(
|
||||
&mut bitmap,
|
||||
rotation,
|
||||
&expected_text,
|
||||
&expected_metadata,
|
||||
true,
|
||||
) {
|
||||
if decoded {
|
||||
try_harder_counts[x] += 1;
|
||||
} else {
|
||||
try_harder_misread_counts[x] += 1;
|
||||
Ok(decoded) => {
|
||||
if decoded {
|
||||
try_harder_counts[x] += 1;
|
||||
} else {
|
||||
try_harder_misread_counts[x] += 1;
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
log::fine(format!("could not read at rotation {rotation} w/TH: {e:?}"));
|
||||
}
|
||||
} else {
|
||||
log::fine(format!("could not read at rotation {rotation} w/TH"));
|
||||
}
|
||||
// try {
|
||||
// if (decode(bitmap, rotation, expectedText, expectedMetadata, true)) {
|
||||
|
||||
@@ -24,7 +24,13 @@ use std::{
|
||||
};
|
||||
|
||||
use encoding::Encoding;
|
||||
use rxing::{common::{HybridBinarizer, Result}, multi::MultipleBarcodeReader, pdf417::PDF417RXingResultMetadata, BarcodeFormat, BinaryBitmap, BufferedImageLuminanceSource, DecodeHintType, DecodeHintValue, RXingResult, RXingResultMetadataType, RXingResultMetadataValue, Reader, Binarizer};
|
||||
use rxing::{
|
||||
common::{HybridBinarizer, Result},
|
||||
multi::MultipleBarcodeReader,
|
||||
pdf417::PDF417RXingResultMetadata,
|
||||
BarcodeFormat, Binarizer, BinaryBitmap, BufferedImageLuminanceSource, DecodeHintType,
|
||||
DecodeHintValue, RXingResult, RXingResultMetadataType, RXingResultMetadataValue, Reader,
|
||||
};
|
||||
|
||||
use super::TestRXingResult;
|
||||
|
||||
@@ -174,8 +180,7 @@ impl<T: MultipleBarcodeReader + Reader> PDF417MultiImageSpanAbstractBlackBoxTest
|
||||
let rotation: f32 = self.test_rxing_results.get(x).expect("ok").get_rotation();
|
||||
let rotated_image = Self::rotate_image(&image, rotation);
|
||||
let source = BufferedImageLuminanceSource::new(rotated_image);
|
||||
let mut bitmap =
|
||||
BinaryBitmap::new(HybridBinarizer::new(source));
|
||||
let mut bitmap = BinaryBitmap::new(HybridBinarizer::new(source));
|
||||
|
||||
if let Ok(res) =
|
||||
Self::decode_pdf417(&mut bitmap, false, &mut self.barcode_reader)
|
||||
|
||||
Reference in New Issue
Block a user