Update tests

This commit is contained in:
Steve Cook
2023-03-01 22:49:07 -05:00
parent c5460debe1
commit 70b1ef270f
10 changed files with 33 additions and 44 deletions

View File

@@ -25,12 +25,7 @@ use std::{
};
use encoding::Encoding;
use rxing::{
common::{HybridBinarizer, Result},
pdf417::PDF417RXingResultMetadata,
BarcodeFormat, BinaryBitmap, BufferedImageLuminanceSource, DecodeHintType, DecodeHintValue,
RXingResultMetadataType, RXingResultMetadataValue, Reader,
};
use rxing::{common::{HybridBinarizer, Result}, pdf417::PDF417RXingResultMetadata, BarcodeFormat, BinaryBitmap, BufferedImageLuminanceSource, DecodeHintType, DecodeHintValue, RXingResultMetadataType, RXingResultMetadataValue, Reader, Binarizer};
use super::TestRXingResult;
@@ -251,7 +246,7 @@ impl<T: Reader> AbstractBlackBoxTestCase<T> {
let rotation = self.test_rxing_results.get(x).unwrap().get_rotation();
let rotated_image = Self::rotate_image(&image, rotation);
let source = BufferedImageLuminanceSource::new(rotated_image);
let mut bitmap = BinaryBitmap::new(Rc::new(HybridBinarizer::new(Box::new(source))));
let mut bitmap = BinaryBitmap::new(HybridBinarizer::new(source));
// if file_base_name == "15" {
// let mut f = File::create("test_file_output.txt").unwrap();
@@ -422,9 +417,9 @@ impl<T: Reader> AbstractBlackBoxTestCase<T> {
}
}
fn decode(
fn decode<B: Binarizer>(
&mut self,
source: &mut BinaryBitmap,
source: &mut BinaryBitmap<B>,
rotation: f32,
expected_text: &str,
expected_metadata: &HashMap<RXingResultMetadataType, RXingResultMetadataValue>,

View File

@@ -24,13 +24,7 @@ use std::{
};
use encoding::Encoding;
use rxing::{
common::{HybridBinarizer, Result},
multi::MultipleBarcodeReader,
pdf417::PDF417RXingResultMetadata,
BarcodeFormat, BinaryBitmap, BufferedImageLuminanceSource, DecodeHintType, DecodeHintValue,
RXingResult, RXingResultMetadataType, RXingResultMetadataValue, Reader,
};
use rxing::{common::{HybridBinarizer, Result}, multi::MultipleBarcodeReader, pdf417::PDF417RXingResultMetadata, BarcodeFormat, BinaryBitmap, BufferedImageLuminanceSource, DecodeHintType, DecodeHintValue, RXingResult, RXingResultMetadataType, RXingResultMetadataValue, Reader, Binarizer};
use super::TestRXingResult;
@@ -181,7 +175,7 @@ impl<T: MultipleBarcodeReader + Reader> PDF417MultiImageSpanAbstractBlackBoxTest
let rotated_image = Self::rotate_image(&image, rotation);
let source = BufferedImageLuminanceSource::new(rotated_image);
let mut bitmap =
BinaryBitmap::new(Rc::new(HybridBinarizer::new(Box::new(source))));
BinaryBitmap::new(HybridBinarizer::new(source));
if let Ok(res) =
Self::decode_pdf417(&mut bitmap, false, &mut self.barcode_reader)
@@ -395,7 +389,7 @@ impl<T: MultipleBarcodeReader + Reader> PDF417MultiImageSpanAbstractBlackBoxTest
let rotation = self.test_rxing_results.get(x).unwrap().get_rotation();
let rotated_image = Self::rotate_image(&image, rotation);
let source = BufferedImageLuminanceSource::new(rotated_image);
let mut bitmap = BinaryBitmap::new(Rc::new(HybridBinarizer::new(Box::new(source))));
let mut bitmap = BinaryBitmap::new(HybridBinarizer::new(source));
// if file_base_name == "15" {
// let mut f = File::create("test_file_output.txt").unwrap();
@@ -566,9 +560,9 @@ impl<T: MultipleBarcodeReader + Reader> PDF417MultiImageSpanAbstractBlackBoxTest
}
}
fn decode(
fn decode<B: Binarizer>(
&mut self,
source: &mut BinaryBitmap,
source: &mut BinaryBitmap<B>,
rotation: f32,
expected_text: &str,
expected_metadata: &HashMap<RXingResultMetadataType, RXingResultMetadataValue>,
@@ -754,8 +748,8 @@ impl<T: MultipleBarcodeReader + Reader> PDF417MultiImageSpanAbstractBlackBoxTest
}
}
fn decode_pdf417(
source: &mut BinaryBitmap,
fn decode_pdf417<B: Binarizer>(
source: &mut BinaryBitmap<B>,
try_harder: bool,
barcode_reader: &mut T,
) -> Result<Vec<RXingResult>> {