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 pdf_417_multiimage_span;
mod multiimage_span;
mod test_result;
pub use abstract_black_box_test_case::*;
pub use pdf_417_multiimage_span::*;
pub use multiimage_span::*;
pub use test_result::*;

View File

@@ -37,7 +37,7 @@ use super::TestRXingResult;
* @author Sean Owen
* @author dswitkin@google.com (Daniel Switkin)
*/
pub struct PDF417MultiImageSpanAbstractBlackBoxTestCase<T: MultipleBarcodeReader + Reader> {
pub struct MultiImageSpanAbstractBlackBoxTestCase<T: MultipleBarcodeReader + Reader> {
test_base: Box<Path>,
barcode_reader: T,
expected_format: BarcodeFormat,
@@ -45,7 +45,7 @@ pub struct PDF417MultiImageSpanAbstractBlackBoxTestCase<T: MultipleBarcodeReader
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> {
// A little workaround to prevent aggravation in my IDE
let test_base = Path::new(test_base_path_suffix);
@@ -198,19 +198,36 @@ impl<T: MultipleBarcodeReader + Reader> PDF417MultiImageSpanAbstractBlackBoxTest
// results.sort();
let mut result_text = String::new(); //new StringBuilder();
let mut file_id: Option<String> = None;
for result in results {
// for (RXingResult result : results) {
let result_metadata = Self::get_meta(&result);
assert!(result_metadata.is_some(), "resultMetadata");
if file_id.is_none() {
file_id = Some(result_metadata.as_ref().unwrap().getFileId().to_owned());
if self.expected_format == BarcodeFormat::PDF_417 {
for result in results {
// for (RXingResult result : results) {
let result_metadata = Self::get_meta(&result);
assert!(result_metadata.is_some(), "resultMetadata");
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");
passed_counts[x] += 1;