integration tests

This commit is contained in:
Henry Schimke
2022-12-10 17:43:58 -06:00
parent 20f8d15065
commit b1684ac698
7 changed files with 46 additions and 36 deletions

View File

@@ -55,3 +55,6 @@ pub use coda_bar_writer::*;
mod multi_format_upc_ean_reader; mod multi_format_upc_ean_reader;
pub use multi_format_upc_ean_reader::*; pub use multi_format_upc_ean_reader::*;
mod code_39_writer;
pub use code_39_writer::*;

View File

@@ -159,8 +159,12 @@ pub trait OneDReader: Reader {
* @throws NotFoundException if counters cannot be filled entirely from row before running out * @throws NotFoundException if counters cannot be filled entirely from row before running out
* of pixels * of pixels
*/ */
fn recordPattern(&self, row: &BitArray, start: usize, counters: &mut [u32]) -> Result<(), Exceptions> fn recordPattern(
{ &self,
row: &BitArray,
start: usize,
counters: &mut [u32],
) -> Result<(), Exceptions> {
let numCounters = counters.len(); let numCounters = counters.len();
// Arrays.fill(counters, 0, numCounters, 0); // Arrays.fill(counters, 0, numCounters, 0);
counters.fill(0); counters.fill(0);
@@ -198,8 +202,7 @@ pub trait OneDReader: Reader {
row: &BitArray, row: &BitArray,
start: usize, start: usize,
counters: &mut [u32], counters: &mut [u32],
) -> Result<(), Exceptions> ) -> Result<(), Exceptions> {
{
let mut start = start; let mut start = start;
// This could be more efficient I guess // This could be more efficient I guess
let mut numTransitionsLeft = counters.len() as isize; let mut numTransitionsLeft = counters.len() as isize;
@@ -229,8 +232,12 @@ pub trait OneDReader: Reader {
* @param maxIndividualVariance The most any counter can differ before we give up * @param maxIndividualVariance The most any counter can differ before we give up
* @return ratio of total variance between counters and pattern compared to total pattern size * @return ratio of total variance between counters and pattern compared to total pattern size
*/ */
fn patternMatchVariance(&self, counters: &[u32], pattern: &[u32], maxIndividualVariance: f32) -> f32 fn patternMatchVariance(
{ &self,
counters: &[u32],
pattern: &[u32],
maxIndividualVariance: f32,
) -> f32 {
let mut maxIndividualVariance = maxIndividualVariance; let mut maxIndividualVariance = maxIndividualVariance;
let numCounters = counters.len(); let numCounters = counters.len();
let mut total = 0.0; let mut total = 0.0;

View File

@@ -75,8 +75,11 @@ impl UPCEANReader for UPCEReader {
self.checkStandardUPCEANChecksum(&convertUPCEtoUPCA(s)) self.checkStandardUPCEANChecksum(&convertUPCEtoUPCA(s))
} }
fn decodeEnd(&self, row: &crate::common::BitArray, endStart: usize) -> Result<[usize; 2], Exceptions> fn decodeEnd(
{ &self,
row: &crate::common::BitArray,
endStart: usize,
) -> Result<[usize; 2], Exceptions> {
self.findGuardPattern(row, endStart, true, &Self::MIDDLE_END_PATTERN) self.findGuardPattern(row, endStart, true, &Self::MIDDLE_END_PATTERN)
} }
} }

View File

@@ -116,8 +116,7 @@ pub trait UPCEANReader: OneDReader {
// eanManSupport = new EANManufacturerOrgSupport(); // eanManSupport = new EANManufacturerOrgSupport();
// } // }
fn findStartGuardPattern(&self, row: &BitArray) -> Result<[usize; 2], Exceptions> fn findStartGuardPattern(&self, row: &BitArray) -> Result<[usize; 2], Exceptions> {
{
let mut foundStart = false; let mut foundStart = false;
let mut startRange = [0; 2]; //= null; let mut startRange = [0; 2]; //= null;
let mut nextStart = 0; let mut nextStart = 0;
@@ -172,8 +171,7 @@ pub trait UPCEANReader: OneDReader {
row: &BitArray, row: &BitArray,
startGuardRange: &[usize; 2], startGuardRange: &[usize; 2],
hints: &crate::DecodingHintDictionary, hints: &crate::DecodingHintDictionary,
) -> Result<RXingResult, Exceptions> ) -> Result<RXingResult, Exceptions> {
{
let resultPointCallback = hints.get(&DecodeHintType::NEED_RESULT_POINT_CALLBACK); let resultPointCallback = hints.get(&DecodeHintType::NEED_RESULT_POINT_CALLBACK);
let mut symbologyIdentifier = 0; let mut symbologyIdentifier = 0;
@@ -380,8 +378,7 @@ pub trait UPCEANReader: OneDReader {
Ok(((1000 - sum) % 10) as u32) Ok(((1000 - sum) % 10) as u32)
} }
fn decodeEnd(&self, row: &BitArray, endStart: usize) -> Result<[usize; 2], Exceptions> fn decodeEnd(&self, row: &BitArray, endStart: usize) -> Result<[usize; 2], Exceptions> {
{
self.findGuardPattern(row, endStart, false, &START_END_PATTERN) self.findGuardPattern(row, endStart, false, &START_END_PATTERN)
} }
@@ -391,8 +388,7 @@ pub trait UPCEANReader: OneDReader {
rowOffset: usize, rowOffset: usize,
whiteFirst: bool, whiteFirst: bool,
pattern: &[u32], pattern: &[u32],
) -> Result<[usize; 2], Exceptions> ) -> Result<[usize; 2], Exceptions> {
{
self.findGuardPatternWithCounters( self.findGuardPatternWithCounters(
row, row,
rowOffset, rowOffset,
@@ -420,8 +416,7 @@ pub trait UPCEANReader: OneDReader {
whiteFirst: bool, whiteFirst: bool,
pattern: &[u32], pattern: &[u32],
counters: &mut [u32], counters: &mut [u32],
) -> Result<[usize; 2], Exceptions> ) -> Result<[usize; 2], Exceptions> {
{
let width = row.getSize(); let width = row.getSize();
let rowOffset = if whiteFirst { let rowOffset = if whiteFirst {
row.getNextUnset(rowOffset) row.getNextUnset(rowOffset)
@@ -479,8 +474,7 @@ pub trait UPCEANReader: OneDReader {
counters: &mut [u32; 4], counters: &mut [u32; 4],
rowOffset: usize, rowOffset: usize,
patterns: &[[u32; 4]], patterns: &[[u32; 4]],
) -> Result<usize, Exceptions> ) -> Result<usize, Exceptions> {
{
self.recordPattern(row, rowOffset, counters)?; self.recordPattern(row, rowOffset, counters)?;
let mut bestVariance = MAX_AVG_VARIANCE; // worst variance we'll accept let mut bestVariance = MAX_AVG_VARIANCE; // worst variance we'll accept
let mut bestMatch = -1_isize; let mut bestMatch = -1_isize;

View File

@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
use rxing::{MultiFormatReader, DecodeHintType, DecodeHintValue}; use rxing::{DecodeHintType, DecodeHintValue, MultiFormatReader};
mod common; mod common;
@@ -29,7 +29,10 @@ use rxing::{MultiFormatReader, DecodeHintType, DecodeHintValue};
rxing::BarcodeFormat::DATA_MATRIX, rxing::BarcodeFormat::DATA_MATRIX,
); );
// super("src/test/resources/blackbox/inverted", new MultiFormatReader(), BarcodeFormat.DATA_MATRIX); // super("src/test/resources/blackbox/inverted", new MultiFormatReader(), BarcodeFormat.DATA_MATRIX);
tester.add_hint(DecodeHintType::ALSO_INVERTED, DecodeHintValue::AlsoInverted(true)); tester.add_hint(
DecodeHintType::ALSO_INVERTED,
DecodeHintValue::AlsoInverted(true),
);
tester.add_test(1, 1, 0.0); tester.add_test(1, 1, 0.0);
tester.add_test(1, 1, 90.0); tester.add_test(1, 1, 90.0);
tester.add_test(1, 1, 180.0); tester.add_test(1, 1, 180.0);