mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-28 05:12:34 +00:00
integration tests
This commit is contained in:
@@ -86,6 +86,6 @@ impl UPCEANReader for EAN8Reader {
|
|||||||
|
|
||||||
impl Default for EAN8Reader {
|
impl Default for EAN8Reader {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self { }
|
Self {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -405,7 +405,7 @@ impl ITFReader {
|
|||||||
* @return The decoded digit
|
* @return The decoded digit
|
||||||
* @throws NotFoundException if digit cannot be decoded
|
* @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 bestVariance = MAX_AVG_VARIANCE; // worst variance we'll accept
|
||||||
let mut bestMatch = -1_isize;
|
let mut bestMatch = -1_isize;
|
||||||
let max = PATTERNS.len();
|
let max = PATTERNS.len();
|
||||||
|
|||||||
@@ -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::*;
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -567,4 +561,4 @@ impl Reader for StandInStruct {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) const StandIn : StandInStruct = StandInStruct{};
|
pub(crate) const StandIn: StandInStruct = StandInStruct {};
|
||||||
|
|||||||
@@ -14,26 +14,29 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use rxing::{MultiFormatReader, DecodeHintType, DecodeHintValue};
|
use rxing::{DecodeHintType, DecodeHintValue, MultiFormatReader};
|
||||||
|
|
||||||
mod common;
|
mod common;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Inverted barcodes
|
* Inverted barcodes
|
||||||
*/
|
*/
|
||||||
#[test]
|
#[test]
|
||||||
fn inverted_data_matrix_black_box_test_case() {
|
fn inverted_data_matrix_black_box_test_case() {
|
||||||
let mut tester = common::AbstractBlackBoxTestCase::new(
|
let mut tester = common::AbstractBlackBoxTestCase::new(
|
||||||
"test_resources/blackbox/inverted",
|
"test_resources/blackbox/inverted",
|
||||||
MultiFormatReader::default(),
|
MultiFormatReader::default(),
|
||||||
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);
|
||||||
tester.add_test(1, 1, 270.0);
|
tester.add_test(1, 1, 270.0);
|
||||||
|
|
||||||
tester.test_black_box();
|
tester.test_black_box();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user