mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 20:32:34 +00:00
cleaned up many warnings
This commit is contained in:
@@ -111,16 +111,16 @@ use rand::Rng;
|
||||
#[test]
|
||||
fn test_get_next_set5() {
|
||||
let mut r = rand::thread_rng();
|
||||
for i in 0 .. 10 {
|
||||
for _i in 0 .. 10 {
|
||||
// for (int i = 0; i < 10; i++) {
|
||||
let mut array = BitArray::with_size(1 + r.gen_range(0..100));
|
||||
let numSet = r.gen_range(0..20);
|
||||
for j in 0..numSet {
|
||||
for _j in 0..numSet {
|
||||
// for (int j = 0; j < numSet; j++) {
|
||||
array.set(r.gen_range(0..array.getSize()));
|
||||
}
|
||||
let numQueries = r.gen_range(0..20);
|
||||
for j in 0..numQueries {
|
||||
for _j in 0..numQueries {
|
||||
// for (int j = 0; j < numQueries; j++) {
|
||||
let query = r.gen_range(0..array.getSize());
|
||||
let mut expected = query;
|
||||
@@ -151,7 +151,7 @@ use rand::Rng;
|
||||
#[test]
|
||||
fn test_append_bit(){
|
||||
let mut array = BitArray::new();
|
||||
array.appendBits(0x000001E, 6);
|
||||
array.appendBits(0x000001E, 6).expect("must append)");
|
||||
let mut array_2 = BitArray::new();
|
||||
array_2.appendBit(false);
|
||||
array_2.appendBit(true);
|
||||
|
||||
@@ -58,7 +58,7 @@ use super::BitMatrix;
|
||||
#[test]
|
||||
fn test_set_region() {
|
||||
let mut matrix = BitMatrix::with_single_dimension(5);
|
||||
matrix.setRegion(1, 1, 3, 3);
|
||||
matrix.setRegion(1, 1, 3, 3).expect("must set");
|
||||
for y in 0..5 {
|
||||
// for (int y = 0; y < 5; y++) {
|
||||
for x in 0..5{
|
||||
@@ -72,11 +72,11 @@ use super::BitMatrix;
|
||||
fn test_enclosing() {
|
||||
let mut matrix = BitMatrix::with_single_dimension(5);
|
||||
assert!(matrix.getEnclosingRectangle().is_none());
|
||||
matrix.setRegion(1, 1, 1, 1);
|
||||
matrix.setRegion(1, 1, 1, 1).expect("must set");
|
||||
assert_eq!(vec![ 1, 1, 1, 1 ], matrix.getEnclosingRectangle().unwrap());
|
||||
matrix.setRegion(1, 1, 3, 2);
|
||||
matrix.setRegion(1, 1, 3, 2).expect("must set");
|
||||
assert_eq!(vec![ 1, 1, 3, 2 ], matrix.getEnclosingRectangle().unwrap());
|
||||
matrix.setRegion(0, 0, 5, 5);
|
||||
matrix.setRegion(0, 0, 5, 5).expect("must set");
|
||||
assert_eq!(vec![ 0, 0, 5, 5 ], matrix.getEnclosingRectangle().unwrap());
|
||||
}
|
||||
|
||||
@@ -85,13 +85,13 @@ use super::BitMatrix;
|
||||
let mut matrix = BitMatrix::with_single_dimension(5);
|
||||
assert!(matrix.getTopLeftOnBit().is_none());
|
||||
assert!(matrix.getBottomRightOnBit().is_none());
|
||||
matrix.setRegion(1, 1, 1, 1);
|
||||
matrix.setRegion(1, 1, 1, 1).expect("must set");
|
||||
assert_eq!(vec![ 1, 1 ], matrix.getTopLeftOnBit().unwrap());
|
||||
assert_eq!(vec![ 1, 1 ], matrix.getBottomRightOnBit().unwrap());
|
||||
matrix.setRegion(1, 1, 3, 2);
|
||||
matrix.setRegion(1, 1, 3, 2).expect("must set");
|
||||
assert_eq!(vec![ 1, 1 ], matrix.getTopLeftOnBit().unwrap());
|
||||
assert_eq!(vec![ 3, 2 ], matrix.getBottomRightOnBit().unwrap());
|
||||
matrix.setRegion(0, 0, 5, 5);
|
||||
matrix.setRegion(0, 0, 5, 5).expect("must set");
|
||||
assert_eq!(vec![ 0, 0 ], matrix.getTopLeftOnBit().unwrap());
|
||||
assert_eq!(vec![ 4, 4 ], matrix.getBottomRightOnBit().unwrap());
|
||||
}
|
||||
@@ -128,7 +128,7 @@ use super::BitMatrix;
|
||||
let mut matrix = BitMatrix::new(320, 240).unwrap();
|
||||
assert_eq!(320, matrix.getWidth());
|
||||
assert_eq!(240, matrix.getHeight());
|
||||
matrix.setRegion(105, 22, 80, 12);
|
||||
matrix.setRegion(105, 22, 80, 12).expect("must set");
|
||||
|
||||
// Only bits in the region should be on
|
||||
for y in 0..240 {
|
||||
@@ -217,9 +217,9 @@ use super::BitMatrix;
|
||||
fn test_parse() {
|
||||
let emptyMatrix = BitMatrix::new(3, 3).unwrap();
|
||||
let mut fullMatrix = BitMatrix::new(3, 3).unwrap();
|
||||
fullMatrix.setRegion(0, 0, 3, 3);
|
||||
fullMatrix.setRegion(0, 0, 3, 3).expect("must set");
|
||||
let mut centerMatrix = BitMatrix::new(3, 3).unwrap();
|
||||
centerMatrix.setRegion(1, 1, 1, 1);
|
||||
centerMatrix.setRegion(1, 1, 1, 1).expect("must set");
|
||||
let emptyMatrix24 = BitMatrix::new(2, 4).unwrap();
|
||||
|
||||
assert_eq!(emptyMatrix, BitMatrix::parse_strings(" \n \n \n", "x", " ").unwrap());
|
||||
@@ -243,9 +243,9 @@ use super::BitMatrix;
|
||||
fn test_parse_boolean() {
|
||||
let emptyMatrix = BitMatrix::new(3, 3).unwrap();
|
||||
let mut fullMatrix = BitMatrix::new(3, 3).unwrap();
|
||||
fullMatrix.setRegion(0, 0, 3, 3);
|
||||
fullMatrix.setRegion(0, 0, 3, 3).expect("must set");
|
||||
let mut centerMatrix = BitMatrix::new(3, 3).unwrap();
|
||||
centerMatrix.setRegion(1, 1, 1, 1);
|
||||
centerMatrix.setRegion(1, 1, 1, 1).expect("must set");
|
||||
let emptyMatrix24 = BitMatrix::new(2, 4).unwrap();
|
||||
|
||||
let mut matrix = vec![vec![false;3];3];
|
||||
@@ -276,9 +276,9 @@ use super::BitMatrix;
|
||||
fn test_xor_case() {
|
||||
let emptyMatrix = BitMatrix::new(3, 3).unwrap();
|
||||
let mut fullMatrix = BitMatrix::new(3, 3).unwrap();
|
||||
fullMatrix.setRegion(0, 0, 3, 3);
|
||||
fullMatrix.setRegion(0, 0, 3, 3).expect("must set");
|
||||
let mut centerMatrix = BitMatrix::new(3, 3).unwrap();
|
||||
centerMatrix.setRegion(1, 1, 1, 1);
|
||||
centerMatrix.setRegion(1, 1, 1, 1).expect("must set");
|
||||
let mut invertedCenterMatrix = fullMatrix.clone();
|
||||
invertedCenterMatrix.unset(1, 1);
|
||||
let badMatrix = BitMatrix::new(4, 4).unwrap();
|
||||
@@ -328,7 +328,7 @@ use super::BitMatrix;
|
||||
|
||||
fn test_XOR( dataMatrix: &BitMatrix, flipMatrix: &BitMatrix, expectedMatrix: &BitMatrix) {
|
||||
let mut matrix = dataMatrix.clone();
|
||||
matrix.xor(flipMatrix);
|
||||
matrix.xor(flipMatrix).expect("must set");
|
||||
assert_eq!(*expectedMatrix, matrix);
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ pub fn sum(array: &[i32]) -> i32 {
|
||||
mod tests {
|
||||
use crate::common::detector::MathUtils;
|
||||
|
||||
static EPSILON: f32 = 1.0E-8f32;
|
||||
// static EPSILON: f32 = 1.0E-8f32;
|
||||
|
||||
#[test]
|
||||
fn testRound() {
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
pub mod MathUtils;
|
||||
use crate::common::BitMatrix;
|
||||
use crate::{Exceptions, RXingResultPoint, ResultPoint};
|
||||
|
||||
mod monochrome_rectangle_detector;
|
||||
pub use monochrome_rectangle_detector::*;
|
||||
|
||||
@@ -245,7 +245,7 @@ impl MonochromeRectangleDetector {
|
||||
|
||||
// Scan left/up first
|
||||
let mut start = center;
|
||||
while (start >= minDim) {
|
||||
while start >= minDim {
|
||||
if if horizontal {
|
||||
self.image.get(start as u32, fixedDimension as u32)
|
||||
} else {
|
||||
@@ -275,7 +275,7 @@ impl MonochromeRectangleDetector {
|
||||
|
||||
// Then try right/down
|
||||
let mut end = center;
|
||||
while (end < maxDim) {
|
||||
while end < maxDim {
|
||||
if if horizontal {
|
||||
self.image.get(end as u32, fixedDimension as u32)
|
||||
} else {
|
||||
|
||||
@@ -171,7 +171,7 @@ impl ECIEncoderSet {
|
||||
// In this case we append a UTF-8 and UTF-16 encoder to the list
|
||||
// encoders = [] new CharsetEncoder[neededEncoders.size() + 2];
|
||||
encoders = Vec::new();
|
||||
let index = 0;
|
||||
// let index = 0;
|
||||
|
||||
for encoder in neededEncoders {
|
||||
// for (CharsetEncoder encoder : neededEncoders) {
|
||||
|
||||
@@ -81,7 +81,7 @@ impl ECIStringBuilder {
|
||||
* @param value string to append
|
||||
*/
|
||||
pub fn append_string(&mut self, value: &str) {
|
||||
value.as_bytes().iter().map(|b| self.current_bytes.push(*b));
|
||||
value.as_bytes().iter().map(|b| self.current_bytes.push(*b)).count();
|
||||
// self.current_bytes.push(value.as_bytes());
|
||||
}
|
||||
|
||||
|
||||
@@ -158,7 +158,7 @@ impl GlobalHistogramBinarizer {
|
||||
const LUMINANCE_BITS: usize = 5;
|
||||
const LUMINANCE_SHIFT: usize = 8 - GlobalHistogramBinarizer::LUMINANCE_BITS;
|
||||
const LUMINANCE_BUCKETS: usize = 1 << GlobalHistogramBinarizer::LUMINANCE_BITS;
|
||||
const EMPTY: [u8; 0] = [0; 0];
|
||||
// const EMPTY: [u8; 0] = [0; 0];
|
||||
|
||||
pub fn new(source: Box<dyn LuminanceSource>) -> Self {
|
||||
Self {
|
||||
|
||||
@@ -160,7 +160,7 @@ pub trait GridSampler {
|
||||
if y == -1 {
|
||||
points[offset + 1] = 0.0f32;
|
||||
nudged = true;
|
||||
} else if (y == height.try_into().unwrap()) {
|
||||
} else if y == height.try_into().unwrap() {
|
||||
points[offset + 1] = height as f32 - 1f32;
|
||||
nudged = true;
|
||||
}
|
||||
|
||||
@@ -1,26 +1,7 @@
|
||||
pub mod detector;
|
||||
pub mod reedsolomon;
|
||||
|
||||
use core::num;
|
||||
use std::any::Any;
|
||||
use std::cmp;
|
||||
use std::collections::HashMap;
|
||||
use std::fmt;
|
||||
use std::rc::Rc;
|
||||
|
||||
use crate::Binarizer;
|
||||
use crate::DecodeHintType;
|
||||
use crate::DecodeHintValue;
|
||||
use crate::DecodingHintDictionary;
|
||||
use crate::Exceptions;
|
||||
use crate::LuminanceSource;
|
||||
use crate::RXingResultPoint;
|
||||
use encoding::Encoding;
|
||||
use encoding::EncodingRef;
|
||||
|
||||
use lazy_static::lazy_static;
|
||||
|
||||
use unicode_segmentation::UnicodeSegmentation;
|
||||
|
||||
#[cfg(test)]
|
||||
mod StringUtilsTestCase;
|
||||
@@ -118,9 +99,6 @@ pub use eci_encoder_set::*;
|
||||
mod minimal_eci_input;
|
||||
pub use minimal_eci_input::*;
|
||||
|
||||
mod input_edge;
|
||||
pub use input_edge::*;
|
||||
|
||||
|
||||
mod global_histogram_binarizer;
|
||||
pub use global_histogram_binarizer::*;
|
||||
|
||||
@@ -19,8 +19,6 @@
|
||||
//import org.junit.Assert;
|
||||
//import org.junit.Test;
|
||||
|
||||
use std::rc::Rc;
|
||||
|
||||
use super::{GenericGF, GenericGFPoly};
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use rand::Rng;
|
||||
|
||||
use super::{GenericGF, GenericGFRef, ReedSolomonDecoder, ReedSolomonEncoder};
|
||||
use super::{GenericGFRef, ReedSolomonDecoder, ReedSolomonEncoder};
|
||||
/*
|
||||
* Copyrigh&t 2013 ZXing authors
|
||||
*
|
||||
|
||||
@@ -1,8 +1,3 @@
|
||||
use std::fmt;
|
||||
|
||||
use crate::Exceptions;
|
||||
use std::hash::Hash;
|
||||
|
||||
#[cfg(test)]
|
||||
mod GenericGFPolyTestCase;
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -53,8 +53,8 @@ pub struct StringUtils {
|
||||
// encoding::label::encoding_from_whatwg_label("GB2312").unwrap();
|
||||
// const EUC_JP: &dyn Encoding = encoding::label::encoding_from_whatwg_label("EUC_JP").unwrap();
|
||||
const ASSUME_SHIFT_JIS: bool = false;
|
||||
static SHIFT_JIS: &'static str = "SJIS";
|
||||
static GB2312: &'static str = "GB2312";
|
||||
// static SHIFT_JIS: &'static str = "SJIS";
|
||||
// static GB2312: &'static str = "GB2312";
|
||||
lazy_static! {
|
||||
pub static ref SHIFT_JIS_CHARSET: EncodingRef =
|
||||
encoding::label::encoding_from_whatwg_label("SJIS").unwrap();
|
||||
|
||||
Reference in New Issue
Block a user