mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 04:12:34 +00:00
integration tests
This commit is contained in:
@@ -86,6 +86,6 @@ impl UPCEANReader for EAN8Reader {
|
||||
|
||||
impl Default for EAN8Reader {
|
||||
fn default() -> Self {
|
||||
Self { }
|
||||
Self {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -405,7 +405,7 @@ impl ITFReader {
|
||||
* @return The decoded digit
|
||||
* @throws NotFoundException if digit cannot be decoded
|
||||
*/
|
||||
fn decodeDigit(&self,counters: &[u32]) -> Result<u32, Exceptions> {
|
||||
fn decodeDigit(&self, counters: &[u32]) -> Result<u32, Exceptions> {
|
||||
let mut bestVariance = MAX_AVG_VARIANCE; // worst variance we'll accept
|
||||
let mut bestMatch = -1_isize;
|
||||
let max = PATTERNS.len();
|
||||
|
||||
@@ -55,3 +55,6 @@ pub use coda_bar_writer::*;
|
||||
|
||||
mod multi_format_upc_ean_reader;
|
||||
pub use multi_format_upc_ean_reader::*;
|
||||
|
||||
mod code_39_writer;
|
||||
pub use code_39_writer::*;
|
||||
|
||||
@@ -159,8 +159,12 @@ pub trait OneDReader: Reader {
|
||||
* @throws NotFoundException if counters cannot be filled entirely from row before running out
|
||||
* 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();
|
||||
// Arrays.fill(counters, 0, numCounters, 0);
|
||||
counters.fill(0);
|
||||
@@ -198,8 +202,7 @@ pub trait OneDReader: Reader {
|
||||
row: &BitArray,
|
||||
start: usize,
|
||||
counters: &mut [u32],
|
||||
) -> Result<(), Exceptions>
|
||||
{
|
||||
) -> Result<(), Exceptions> {
|
||||
let mut start = start;
|
||||
// This could be more efficient I guess
|
||||
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
|
||||
* @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 numCounters = counters.len();
|
||||
let mut total = 0.0;
|
||||
|
||||
@@ -75,8 +75,11 @@ impl UPCEANReader for UPCEReader {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,8 +116,7 @@ pub trait UPCEANReader: OneDReader {
|
||||
// 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 startRange = [0; 2]; //= null;
|
||||
let mut nextStart = 0;
|
||||
@@ -172,8 +171,7 @@ pub trait UPCEANReader: OneDReader {
|
||||
row: &BitArray,
|
||||
startGuardRange: &[usize; 2],
|
||||
hints: &crate::DecodingHintDictionary,
|
||||
) -> Result<RXingResult, Exceptions>
|
||||
{
|
||||
) -> Result<RXingResult, Exceptions> {
|
||||
let resultPointCallback = hints.get(&DecodeHintType::NEED_RESULT_POINT_CALLBACK);
|
||||
let mut symbologyIdentifier = 0;
|
||||
|
||||
@@ -380,19 +378,17 @@ pub trait UPCEANReader: OneDReader {
|
||||
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)
|
||||
}
|
||||
|
||||
fn findGuardPattern(
|
||||
&self,
|
||||
&self,
|
||||
row: &BitArray,
|
||||
rowOffset: usize,
|
||||
whiteFirst: bool,
|
||||
pattern: &[u32],
|
||||
) -> Result<[usize; 2], Exceptions>
|
||||
{
|
||||
) -> Result<[usize; 2], Exceptions> {
|
||||
self.findGuardPatternWithCounters(
|
||||
row,
|
||||
rowOffset,
|
||||
@@ -414,14 +410,13 @@ pub trait UPCEANReader: OneDReader {
|
||||
* @throws NotFoundException if pattern is not found
|
||||
*/
|
||||
fn findGuardPatternWithCounters(
|
||||
&self,
|
||||
&self,
|
||||
row: &BitArray,
|
||||
rowOffset: usize,
|
||||
whiteFirst: bool,
|
||||
pattern: &[u32],
|
||||
counters: &mut [u32],
|
||||
) -> Result<[usize; 2], Exceptions>
|
||||
{
|
||||
) -> Result<[usize; 2], Exceptions> {
|
||||
let width = row.getSize();
|
||||
let rowOffset = if whiteFirst {
|
||||
row.getNextUnset(rowOffset)
|
||||
@@ -474,13 +469,12 @@ pub trait UPCEANReader: OneDReader {
|
||||
* @throws NotFoundException if digit cannot be decoded
|
||||
*/
|
||||
fn decodeDigit(
|
||||
&self,
|
||||
&self,
|
||||
row: &BitArray,
|
||||
counters: &mut [u32; 4],
|
||||
rowOffset: usize,
|
||||
patterns: &[[u32; 4]],
|
||||
) -> Result<usize, Exceptions>
|
||||
{
|
||||
) -> Result<usize, Exceptions> {
|
||||
self.recordPattern(row, rowOffset, counters)?;
|
||||
let mut bestVariance = MAX_AVG_VARIANCE; // worst variance we'll accept
|
||||
let mut bestMatch = -1_isize;
|
||||
@@ -567,4 +561,4 @@ impl Reader for StandInStruct {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) const StandIn : StandInStruct = StandInStruct{};
|
||||
pub(crate) const StandIn: StandInStruct = StandInStruct {};
|
||||
|
||||
Reference in New Issue
Block a user