datamatrix fails but could be an issue with text

This commit is contained in:
Henry Schimke
2023-04-28 17:12:53 -05:00
parent 57d4f82e7c
commit e05fae5b6a
4 changed files with 35 additions and 18 deletions

View File

@@ -1,7 +1,7 @@
mod abstract_black_box_test_case; mod abstract_black_box_test_case;
mod pdf_417_multiimage_span; mod multiimage_span;
mod test_result; mod test_result;
pub use abstract_black_box_test_case::*; pub use abstract_black_box_test_case::*;
pub use pdf_417_multiimage_span::*; pub use multiimage_span::*;
pub use test_result::*; pub use test_result::*;

View File

@@ -37,7 +37,7 @@ use super::TestRXingResult;
* @author Sean Owen * @author Sean Owen
* @author dswitkin@google.com (Daniel Switkin) * @author dswitkin@google.com (Daniel Switkin)
*/ */
pub struct PDF417MultiImageSpanAbstractBlackBoxTestCase<T: MultipleBarcodeReader + Reader> { pub struct MultiImageSpanAbstractBlackBoxTestCase<T: MultipleBarcodeReader + Reader> {
test_base: Box<Path>, test_base: Box<Path>,
barcode_reader: T, barcode_reader: T,
expected_format: BarcodeFormat, expected_format: BarcodeFormat,
@@ -45,7 +45,7 @@ pub struct PDF417MultiImageSpanAbstractBlackBoxTestCase<T: MultipleBarcodeReader
hints: HashMap<DecodeHintType, DecodeHintValue>, hints: HashMap<DecodeHintType, DecodeHintValue>,
} }
impl<T: MultipleBarcodeReader + Reader> PDF417MultiImageSpanAbstractBlackBoxTestCase<T> { impl<T: MultipleBarcodeReader + Reader> MultiImageSpanAbstractBlackBoxTestCase<T> {
pub fn build_test_base(test_base_path_suffix: &str) -> Box<Path> { pub fn build_test_base(test_base_path_suffix: &str) -> Box<Path> {
// A little workaround to prevent aggravation in my IDE // A little workaround to prevent aggravation in my IDE
let test_base = Path::new(test_base_path_suffix); let test_base = Path::new(test_base_path_suffix);
@@ -198,19 +198,36 @@ impl<T: MultipleBarcodeReader + Reader> PDF417MultiImageSpanAbstractBlackBoxTest
// results.sort(); // results.sort();
let mut result_text = String::new(); //new StringBuilder(); let mut result_text = String::new(); //new StringBuilder();
let mut file_id: Option<String> = None; let mut file_id: Option<String> = None;
for result in results { if self.expected_format == BarcodeFormat::PDF_417 {
// for (RXingResult result : results) { for result in results {
let result_metadata = Self::get_meta(&result); // for (RXingResult result : results) {
assert!(result_metadata.is_some(), "resultMetadata"); let result_metadata = Self::get_meta(&result);
if file_id.is_none() { assert!(result_metadata.is_some(), "resultMetadata");
file_id = Some(result_metadata.as_ref().unwrap().getFileId().to_owned()); if file_id.is_none() {
file_id =
Some(result_metadata.as_ref().unwrap().getFileId().to_owned());
}
assert_eq!(
file_id,
Some(result_metadata.as_ref().unwrap().getFileId().to_owned()),
"FileId"
);
result_text.push_str(result.getText());
}
} else if self.expected_format != BarcodeFormat::PDF_417 {
results.sort_by_key(|r| {
if let Some(RXingResultMetadataValue::StructuredAppendSequence(md)) = r
.getRXingResultMetadata()
.get(&RXingResultMetadataType::STRUCTURED_APPEND_SEQUENCE)
{
*md
} else {
0
}
});
for result in results {
result_text.push_str(result.getText());
} }
assert_eq!(
file_id,
Some(result_metadata.as_ref().unwrap().getFileId().to_owned()),
"FileId"
);
result_text.push_str(result.getText());
} }
assert_eq!(expected_text, result_text, "ExpectedText"); assert_eq!(expected_text, result_text, "ExpectedText");
passed_counts[x] += 1; passed_counts[x] += 1;

View File

@@ -300,7 +300,7 @@ fn cpp_qrcode_black_box6_test_case() {
#[test] #[test]
fn cpp_qrcode_black_box7_test_case() { fn cpp_qrcode_black_box7_test_case() {
let mut tester = common::PDF417MultiImageSpanAbstractBlackBoxTestCase::new( let mut tester = common::MultiImageSpanAbstractBlackBoxTestCase::new(
"test_resources/blackbox/cpp/qrcode-7", "test_resources/blackbox/cpp/qrcode-7",
QrReader::default(), QrReader::default(),
rxing::BarcodeFormat::QR_CODE, rxing::BarcodeFormat::QR_CODE,

View File

@@ -25,7 +25,7 @@ use rxing::pdf417::PDF417Reader;
*/ */
#[test] #[test]
fn pdf417_black_box4_test_case() { fn pdf417_black_box4_test_case() {
let mut tester = common::PDF417MultiImageSpanAbstractBlackBoxTestCase::new( let mut tester = common::MultiImageSpanAbstractBlackBoxTestCase::new(
"test_resources/blackbox/pdf417-4", "test_resources/blackbox/pdf417-4",
PDF417Reader::default(), PDF417Reader::default(),
rxing::BarcodeFormat::PDF_417, rxing::BarcodeFormat::PDF_417,