mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 04:12:34 +00:00
cargo clippy --fix
This commit is contained in:
@@ -77,8 +77,7 @@ fn test_high_level_decode_string(expectedString: &str, b: &str) {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
expectedString,
|
expectedString,
|
||||||
decoder::highLevelDecode(&toBooleanArray(&bits)).expect("highLevelDecode Failed"),
|
decoder::highLevelDecode(&toBooleanArray(&bits)).expect("highLevelDecode Failed"),
|
||||||
"highLevelDecode() failed for input bits: {}",
|
"highLevelDecode() failed for input bits: {b}"
|
||||||
b
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ fn test_error_in_parameter_locator_compact() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_error_in_parameter_locator_not_compact() {
|
fn test_error_in_parameter_locator_not_compact() {
|
||||||
let alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYabcdefghijklmnopqrstuvwxyz";
|
let alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYabcdefghijklmnopqrstuvwxyz";
|
||||||
test_error_in_parameter_locator(&format!("{}{}{}", alphabet, alphabet, alphabet));
|
test_error_in_parameter_locator(&format!("{alphabet}{alphabet}{alphabet}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -165,7 +165,7 @@ fn test_error_in_parameter_locator(data: &str) {
|
|||||||
if let Exceptions::NotFoundException(_msg) = res {
|
if let Exceptions::NotFoundException(_msg) = res {
|
||||||
// all ok
|
// all ok
|
||||||
} else {
|
} else {
|
||||||
panic!("Only Exceptions::NotFoundException allowed, got {}", res);
|
panic!("Only Exceptions::NotFoundException allowed, got {res}");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let r = Detector::new(&make_larger(©, 3)).detect(false);
|
let r = Detector::new(&make_larger(©, 3)).detect(false);
|
||||||
|
|||||||
@@ -617,7 +617,7 @@ fn testBorderCompact4CaseFailed() {
|
|||||||
// be error correction
|
// be error correction
|
||||||
let alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
let alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||||
// encodes as 26 * 5 * 4 = 520 bits of data
|
// encodes as 26 * 5 * 4 = 520 bits of data
|
||||||
let alphabet4 = format!("{}{}{}{}", alphabet, alphabet, alphabet, alphabet);
|
let alphabet4 = format!("{alphabet}{alphabet}{alphabet}{alphabet}");
|
||||||
aztec_encoder::encode(&alphabet4, 0, -4).expect("encode");
|
aztec_encoder::encode(&alphabet4, 0, -4).expect("encode");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -627,7 +627,7 @@ fn testBorderCompact4Case() {
|
|||||||
// be error correction
|
// be error correction
|
||||||
let alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
let alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||||
// encodes as 26 * 5 * 4 = 520 bits of data
|
// encodes as 26 * 5 * 4 = 520 bits of data
|
||||||
let alphabet4 = format!("{}{}{}{}", alphabet, alphabet, alphabet, alphabet);
|
let alphabet4 = format!("{alphabet}{alphabet}{alphabet}{alphabet}");
|
||||||
|
|
||||||
// If we just try to encode it normally, it will go to a non-compact 4 layer
|
// If we just try to encode it normally, it will go to a non-compact 4 layer
|
||||||
let mut aztecCode = aztec_encoder::encode(&alphabet4, 0, aztec_encoder::DEFAULT_AZTEC_LAYERS)
|
let mut aztecCode = aztec_encoder::encode(&alphabet4, 0, aztec_encoder::DEFAULT_AZTEC_LAYERS)
|
||||||
@@ -658,7 +658,7 @@ fn testEncode(data: &str, compact: bool, layers: u32, expected: &str) {
|
|||||||
|
|
||||||
// let mut xored = BitMatrix::parse_strings(&stripSpace(expected), "X ", " ").expect("should parse");
|
// let mut xored = BitMatrix::parse_strings(&stripSpace(expected), "X ", " ").expect("should parse");
|
||||||
// xored.xor(matrix).expect("should xor");
|
// xored.xor(matrix).expect("should xor");
|
||||||
assert_eq!(expected, matrix.to_string(), "encode({}) failed", data);
|
assert_eq!(expected, matrix.to_string(), "encode({data}) failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn testEncodeDecode(data: &str, compact: bool, layers: u32) {
|
fn testEncodeDecode(data: &str, compact: bool, layers: u32) {
|
||||||
@@ -814,8 +814,7 @@ fn testStuffBits(wordSize: usize, bits: &str, expected: &str) {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
stripSpace(expected),
|
stripSpace(expected),
|
||||||
stripSpace(&stuffed.to_string()),
|
stripSpace(&stuffed.to_string()),
|
||||||
"stuffBits() failed for input string: {}",
|
"stuffBits() failed for input string: {bits}"
|
||||||
bits
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -838,8 +837,7 @@ fn testHighLevelEncodeStringUtf8(s: &str, expectedBits: &str) {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
stripSpace(expectedBits),
|
stripSpace(expectedBits),
|
||||||
receivedBits,
|
receivedBits,
|
||||||
"highLevelEncode() failed for input string: {}",
|
"highLevelEncode() failed for input string: {s}"
|
||||||
s
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -856,8 +854,7 @@ fn testHighLevelEncodeString(s: &str, expectedBits: &str) {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
stripSpace(expectedBits),
|
stripSpace(expectedBits),
|
||||||
receivedBits,
|
receivedBits,
|
||||||
"highLevelEncode() failed for input string: {}",
|
"highLevelEncode() failed for input string: {s}"
|
||||||
s
|
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
s,
|
s,
|
||||||
@@ -888,7 +885,6 @@ fn testHighLevelEncodeStringCount(s: &str, expectedReceivedBits: u32) {
|
|||||||
// );
|
// );
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
expectedReceivedBits as usize, receivedBitCount,
|
expectedReceivedBits as usize, receivedBitCount,
|
||||||
"highLevelEncode() failed for input string: {} with byte count ({}!={})",
|
"highLevelEncode() failed for input string: {s} with byte count ({expectedReceivedBits}!={receivedBitCount})"
|
||||||
s, expectedReceivedBits, receivedBitCount
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,8 +107,7 @@ fn encode(
|
|||||||
) -> Result<BitMatrix, Exceptions> {
|
) -> Result<BitMatrix, Exceptions> {
|
||||||
if format != BarcodeFormat::AZTEC {
|
if format != BarcodeFormat::AZTEC {
|
||||||
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||||
"can only encode AZTEC, but got {:?}",
|
"can only encode AZTEC, but got {format:?}"
|
||||||
format
|
|
||||||
))));
|
))));
|
||||||
}
|
}
|
||||||
let aztec = if let Some(cset) = charset {
|
let aztec = if let Some(cset) = charset {
|
||||||
|
|||||||
@@ -350,8 +350,7 @@ fn correct_bits(
|
|||||||
let num_codewords = rawbits.len() / codeword_size;
|
let num_codewords = rawbits.len() / codeword_size;
|
||||||
if num_codewords < num_data_codewords as usize {
|
if num_codewords < num_data_codewords as usize {
|
||||||
return Err(Exceptions::FormatException(Some(format!(
|
return Err(Exceptions::FormatException(Some(format!(
|
||||||
"numCodewords {}< numDataCodewords{}",
|
"numCodewords {num_codewords}< numDataCodewords{num_data_codewords}"
|
||||||
num_codewords, num_data_codewords
|
|
||||||
))));
|
))));
|
||||||
}
|
}
|
||||||
let mut offset = rawbits.len() % codeword_size;
|
let mut offset = rawbits.len() % codeword_size;
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ pub const WORD_SIZE: [u32; 33] = [
|
|||||||
pub fn encode_simple(data: &str) -> Result<AztecCode, Exceptions> {
|
pub fn encode_simple(data: &str) -> Result<AztecCode, Exceptions> {
|
||||||
let Ok(bytes) = encoding::all::ISO_8859_1
|
let Ok(bytes) = encoding::all::ISO_8859_1
|
||||||
.encode(data, encoding::EncoderTrap::Replace) else {
|
.encode(data, encoding::EncoderTrap::Replace) else {
|
||||||
return Err(Exceptions::IllegalArgumentException(Some(format!("'{}' cannot be encoded as ISO_8859_1", data))));
|
return Err(Exceptions::IllegalArgumentException(Some(format!("'{data}' cannot be encoded as ISO_8859_1"))));
|
||||||
};
|
};
|
||||||
encode_bytes_simple(&bytes)
|
encode_bytes_simple(&bytes)
|
||||||
}
|
}
|
||||||
@@ -76,8 +76,7 @@ pub fn encode(
|
|||||||
encode_bytes(&bytes, minECCPercent, userSpecifiedLayers)
|
encode_bytes(&bytes, minECCPercent, userSpecifiedLayers)
|
||||||
} else {
|
} else {
|
||||||
Err(Exceptions::IllegalArgumentException(Some(format!(
|
Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||||
"'{}' cannot be encoded as ISO_8859_1",
|
"'{data}' cannot be encoded as ISO_8859_1"
|
||||||
data
|
|
||||||
))))
|
))))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -104,8 +103,7 @@ pub fn encode_with_charset(
|
|||||||
encode_bytes_with_charset(&bytes, minECCPercent, userSpecifiedLayers, charset)
|
encode_bytes_with_charset(&bytes, minECCPercent, userSpecifiedLayers, charset)
|
||||||
} else {
|
} else {
|
||||||
Err(Exceptions::IllegalArgumentException(Some(format!(
|
Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||||
"'{}' cannot be encoded as ISO_8859_1",
|
"'{data}' cannot be encoded as ISO_8859_1"
|
||||||
data
|
|
||||||
))))
|
))))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -181,8 +179,7 @@ pub fn encode_bytes_with_charset(
|
|||||||
})
|
})
|
||||||
{
|
{
|
||||||
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||||
"Illegal value {} for layers",
|
"Illegal value {user_specified_layers} for layers"
|
||||||
user_specified_layers
|
|
||||||
))));
|
))));
|
||||||
}
|
}
|
||||||
total_bits_in_layer_var = total_bits_in_layer(layers, compact);
|
total_bits_in_layer_var = total_bits_in_layer(layers, compact);
|
||||||
@@ -498,8 +495,7 @@ fn getGF(wordSize: usize) -> Result<GenericGFRef, Exceptions> {
|
|||||||
10 => Ok(get_predefined_genericgf(PredefinedGenericGF::AztecData10)),
|
10 => Ok(get_predefined_genericgf(PredefinedGenericGF::AztecData10)),
|
||||||
12 => Ok(get_predefined_genericgf(PredefinedGenericGF::AztecData12)),
|
12 => Ok(get_predefined_genericgf(PredefinedGenericGF::AztecData12)),
|
||||||
_ => Err(Exceptions::IllegalArgumentException(Some(format!(
|
_ => Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||||
"Unsupported word size {}",
|
"Unsupported word size {wordSize}"
|
||||||
wordSize
|
|
||||||
)))),
|
)))),
|
||||||
}
|
}
|
||||||
// switch (wordSize) {
|
// switch (wordSize) {
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ impl State {
|
|||||||
// throw new IllegalArgumentException("ECI code must be between 0 and 999999");
|
// throw new IllegalArgumentException("ECI code must be between 0 and 999999");
|
||||||
} else {
|
} else {
|
||||||
let eci_digits = encoding::all::ISO_8859_1
|
let eci_digits = encoding::all::ISO_8859_1
|
||||||
.encode(&format!("{}", eci), encoding::EncoderTrap::Strict)
|
.encode(&format!("{eci}"), encoding::EncoderTrap::Strict)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
// let eciDigits = Integer.toString(eci).getBytes(StandardCharsets.ISO_8859_1);
|
// let eciDigits = Integer.toString(eci).getBytes(StandardCharsets.ISO_8859_1);
|
||||||
token.add(eci_digits.len() as i32, 3); // 1-6: number of ECI digits
|
token.add(eci_digits.len() as i32, 3); // 1-6: number of ECI digits
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ fn matchMultipleValuePrefix(prefix: &str, rawText: &str) -> Vec<String> {
|
|||||||
for i in 1..=3 {
|
for i in 1..=3 {
|
||||||
// for (int i = 1; i <= 3; i++) {
|
// for (int i = 1; i <= 3; i++) {
|
||||||
let value = ResultParser::matchSinglePrefixedField(
|
let value = ResultParser::matchSinglePrefixedField(
|
||||||
&format!("{}{}:", prefix, i),
|
&format!("{prefix}{i}:"),
|
||||||
rawText,
|
rawText,
|
||||||
'\r',
|
'\r',
|
||||||
true,
|
true,
|
||||||
|
|||||||
@@ -123,6 +123,6 @@ fn buildName(firstName: &str, lastName: &str) -> String {
|
|||||||
} else if lastName.is_empty() {
|
} else if lastName.is_empty() {
|
||||||
firstName.to_owned()
|
firstName.to_owned()
|
||||||
} else {
|
} else {
|
||||||
format!("{} {}", firstName, lastName)
|
format!("{firstName} {lastName}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -196,8 +196,7 @@ impl CalendarParsedRXingResult {
|
|||||||
return match Utc.datetime_from_str(&when, "%Y%m%dT%H%M%SZ") {
|
return match Utc.datetime_from_str(&when, "%Y%m%dT%H%M%SZ") {
|
||||||
Ok(dtm) => Ok(dtm.with_timezone(&Utc).timestamp()),
|
Ok(dtm) => Ok(dtm.with_timezone(&Utc).timestamp()),
|
||||||
Err(e) => Err(Exceptions::ParseException(Some(format!(
|
Err(e) => Err(Exceptions::ParseException(Some(format!(
|
||||||
"couldn't parse string: {}",
|
"couldn't parse string: {e}"
|
||||||
e
|
|
||||||
)))),
|
)))),
|
||||||
};
|
};
|
||||||
// let dtm = DateTime::parse_from_str(&when, "%Y%m%dT%H%M%S").unwrap().with_timezone(&Utc);
|
// let dtm = DateTime::parse_from_str(&when, "%Y%m%dT%H%M%S").unwrap().with_timezone(&Utc);
|
||||||
@@ -219,16 +218,14 @@ impl CalendarParsedRXingResult {
|
|||||||
Ok(time_zone) => time_zone,
|
Ok(time_zone) => time_zone,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
return Err(Exceptions::ParseException(Some(format!(
|
return Err(Exceptions::ParseException(Some(format!(
|
||||||
"couldn't parse timezone '{}': {}",
|
"couldn't parse timezone '{tz_part}': {e}"
|
||||||
tz_part, e
|
|
||||||
))))
|
))))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return match Utc.datetime_from_str(time_part, "%Y%m%dT%H%M%S") {
|
return match Utc.datetime_from_str(time_part, "%Y%m%dT%H%M%S") {
|
||||||
Ok(dtm) => Ok(dtm.with_timezone(&tz_parsed).timestamp()),
|
Ok(dtm) => Ok(dtm.with_timezone(&tz_parsed).timestamp()),
|
||||||
Err(e) => Err(Exceptions::ParseException(Some(format!(
|
Err(e) => Err(Exceptions::ParseException(Some(format!(
|
||||||
"couldn't parse string: {}",
|
"couldn't parse string: {e}"
|
||||||
e
|
|
||||||
)))),
|
)))),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -238,8 +235,7 @@ impl CalendarParsedRXingResult {
|
|||||||
return match Utc.datetime_from_str(&when, "%Y%m%dT%H%M%S") {
|
return match Utc.datetime_from_str(&when, "%Y%m%dT%H%M%S") {
|
||||||
Ok(dtm) => Ok(dtm.timestamp()),
|
Ok(dtm) => Ok(dtm.timestamp()),
|
||||||
Err(e) => Err(Exceptions::ParseException(Some(format!(
|
Err(e) => Err(Exceptions::ParseException(Some(format!(
|
||||||
"couldn't parse local time: {}",
|
"couldn't parse local time: {e}"
|
||||||
e
|
|
||||||
)))),
|
)))),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -300,8 +296,7 @@ impl CalendarParsedRXingResult {
|
|||||||
Ok(dtm.timestamp())
|
Ok(dtm.timestamp())
|
||||||
} else {
|
} else {
|
||||||
Err(Exceptions::ParseException(Some(format!(
|
Err(Exceptions::ParseException(Some(format!(
|
||||||
"Couldn't parse {}",
|
"Couldn't parse {dateTimeString}"
|
||||||
dateTimeString
|
|
||||||
))))
|
))))
|
||||||
}
|
}
|
||||||
// DateFormat format = new SimpleDateFormat("yyyyMMdd'T'HHmmss", Locale.ENGLISH);
|
// DateFormat format = new SimpleDateFormat("yyyyMMdd'T'HHmmss", Locale.ENGLISH);
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ fn testRSSExpanded() {
|
|||||||
let ev = epr_res.getUncommonAIs().get(k).unwrap();
|
let ev = epr_res.getUncommonAIs().get(k).unwrap();
|
||||||
assert_eq!(v, ev);
|
assert_eq!(v, ev);
|
||||||
} else {
|
} else {
|
||||||
panic!("key not found {}", k)
|
panic!("key not found {k}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// assert_eq!(&uncommonAIs, epr_res.getUncommonAIs());
|
// assert_eq!(&uncommonAIs, epr_res.getUncommonAIs());
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ fn doTest(contents: &str, number: &str, title: &str) {
|
|||||||
if let ParsedClientResult::TelResult(telRXingResult) = result {
|
if let ParsedClientResult::TelResult(telRXingResult) = result {
|
||||||
assert_eq!(number, telRXingResult.getNumber());
|
assert_eq!(number, telRXingResult.getNumber());
|
||||||
assert_eq!(title, telRXingResult.getTitle());
|
assert_eq!(title, telRXingResult.getTitle());
|
||||||
assert_eq!(format!("tel:{}", number), telRXingResult.getTelURI());
|
assert_eq!(format!("tel:{number}"), telRXingResult.getTelURI());
|
||||||
} else {
|
} else {
|
||||||
panic!("wrong return type, expected TelResult");
|
panic!("wrong return type, expected TelResult");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ pub fn parse(theRXingResult: &crate::RXingResult) -> Option<ParsedClientResult>
|
|||||||
}
|
}
|
||||||
// Normalize "TEL:" to "tel:"
|
// Normalize "TEL:" to "tel:"
|
||||||
let telURI = if let Some(stripped) = rawText.strip_prefix("TEL:") {
|
let telURI = if let Some(stripped) = rawText.strip_prefix("TEL:") {
|
||||||
format!("tel:{}", stripped)
|
format!("tel:{stripped}")
|
||||||
} else {
|
} else {
|
||||||
rawText.clone()
|
rawText.clone()
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -182,7 +182,7 @@ pub fn matchVCardPrefixedField(
|
|||||||
|
|
||||||
// At start or after newline, match prefix, followed by optional metadata
|
// At start or after newline, match prefix, followed by optional metadata
|
||||||
// (led by ;) ultimately ending in colon
|
// (led by ;) ultimately ending in colon
|
||||||
let matcher_primary = Regex::new(&format!("(?:^|\\n)(?i:{})(?:;([^:]*))?:", prefix)).unwrap();
|
let matcher_primary = Regex::new(&format!("(?:^|\\n)(?i:{prefix})(?:;([^:]*))?:")).unwrap();
|
||||||
// let matcher_primary = Regex::new(&format!("(?:^|\n){}(.*)", prefix)).unwrap();
|
// let matcher_primary = Regex::new(&format!("(?:^|\n){}(.*)", prefix)).unwrap();
|
||||||
|
|
||||||
//let lower_case_raw_text = rawText.to_lowercase();
|
//let lower_case_raw_text = rawText.to_lowercase();
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ fn matchSingleVCardPrefixedField(prefix: &str, rawText: &str) -> String {
|
|||||||
"".to_owned()
|
"".to_owned()
|
||||||
};
|
};
|
||||||
let root_time = values.last().unwrap().clone();
|
let root_time = values.last().unwrap().clone();
|
||||||
format!("{}{}", root_time, tz_mod)
|
format!("{root_time}{tz_mod}")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
"".to_owned()
|
"".to_owned()
|
||||||
|
|||||||
@@ -45,12 +45,12 @@ fn test_get_next_set1() {
|
|||||||
let array = BitArray::with_size(32);
|
let array = BitArray::with_size(32);
|
||||||
for i in 0..array.getSize() {
|
for i in 0..array.getSize() {
|
||||||
// for (int i = 0; i < array.getSize(); i++) {
|
// for (int i = 0; i < array.getSize(); i++) {
|
||||||
assert_eq!(32, array.getNextSet(i), "{}", i);
|
assert_eq!(32, array.getNextSet(i), "{i}");
|
||||||
}
|
}
|
||||||
let array = BitArray::with_size(33);
|
let array = BitArray::with_size(33);
|
||||||
for i in 0..array.getSize() {
|
for i in 0..array.getSize() {
|
||||||
// for (int i = 0; i < array.getSize(); i++) {
|
// for (int i = 0; i < array.getSize(); i++) {
|
||||||
assert_eq!(33, array.getNextSet(i), "{}", i);
|
assert_eq!(33, array.getNextSet(i), "{i}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,13 +60,13 @@ fn test_get_next_set2() {
|
|||||||
array.set(31);
|
array.set(31);
|
||||||
for i in 0..array.getSize() {
|
for i in 0..array.getSize() {
|
||||||
// for (int i = 0; i < array.getSize(); i++) {
|
// for (int i = 0; i < array.getSize(); i++) {
|
||||||
assert_eq!(if i <= 31 { 31 } else { 33 }, array.getNextSet(i), "{}", i);
|
assert_eq!(if i <= 31 { 31 } else { 33 }, array.getNextSet(i), "{i}");
|
||||||
}
|
}
|
||||||
array = BitArray::with_size(33);
|
array = BitArray::with_size(33);
|
||||||
array.set(32);
|
array.set(32);
|
||||||
for i in 0..array.getSize() {
|
for i in 0..array.getSize() {
|
||||||
// for (int i = 0; i < array.getSize(); i++) {
|
// for (int i = 0; i < array.getSize(); i++) {
|
||||||
assert_eq!(32, array.getNextSet(i), "{}", i);
|
assert_eq!(32, array.getNextSet(i), "{i}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,7 +85,7 @@ fn test_get_next_set3() {
|
|||||||
} else {
|
} else {
|
||||||
expected = 63;
|
expected = 63;
|
||||||
}
|
}
|
||||||
assert_eq!(expected, array.getNextSet(i), "{}", i);
|
assert_eq!(expected, array.getNextSet(i), "{i}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,7 +104,7 @@ fn test_get_next_set4() {
|
|||||||
} else {
|
} else {
|
||||||
expected = 63;
|
expected = 63;
|
||||||
}
|
}
|
||||||
assert_eq!(expected, array.getNextSet(i), "{}", i);
|
assert_eq!(expected, array.getNextSet(i), "{i}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -393,7 +393,7 @@ impl fmt::Display for BitArray {
|
|||||||
}
|
}
|
||||||
_str.push_str(if self.get(i) { "X" } else { "." });
|
_str.push_str(if self.get(i) { "X" } else { "." });
|
||||||
}
|
}
|
||||||
write!(f, "{}", _str)
|
write!(f, "{_str}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -367,7 +367,7 @@ fn test_rotate_180(width: u32, height: u32) {
|
|||||||
// for (int y = 0; y < height; y++) {
|
// for (int y = 0; y < height; y++) {
|
||||||
for x in 0..width {
|
for x in 0..width {
|
||||||
// for (int x = 0; x < width; x++) {
|
// for (int x = 0; x < width; x++) {
|
||||||
assert_eq!(expected.get(x, y), input.get(x, y), "({},{})", x, y);
|
assert_eq!(expected.get(x, y), input.get(x, y), "({x},{y})");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ impl ECIStringBuilder {
|
|||||||
* @param value int to append as a string
|
* @param value int to append as a string
|
||||||
*/
|
*/
|
||||||
pub fn append(&mut self, value: i32) {
|
pub fn append(&mut self, value: i32) {
|
||||||
self.append_string(&format!("{}", value));
|
self.append_string(&format!("{value}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -79,8 +79,7 @@ impl ECIInput for MinimalECIInput {
|
|||||||
}
|
}
|
||||||
if self.isECI(index as u32)? {
|
if self.isECI(index as u32)? {
|
||||||
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||||
"value at {} is not a character but an ECI",
|
"value at {index} is not a character but an ECI"
|
||||||
index
|
|
||||||
))));
|
))));
|
||||||
}
|
}
|
||||||
if self.isFNC1(index)? {
|
if self.isFNC1(index)? {
|
||||||
@@ -119,8 +118,7 @@ impl ECIInput for MinimalECIInput {
|
|||||||
// for (int i = start; i < end; i++) {
|
// for (int i = start; i < end; i++) {
|
||||||
if self.isECI(i as u32)? {
|
if self.isECI(i as u32)? {
|
||||||
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||||
"value at {} is not a character but an ECI",
|
"value at {i} is not a character but an ECI"
|
||||||
i
|
|
||||||
))));
|
))));
|
||||||
}
|
}
|
||||||
result.push_str(&self.charAt(i)?.to_string());
|
result.push_str(&self.charAt(i)?.to_string());
|
||||||
@@ -170,8 +168,7 @@ impl ECIInput for MinimalECIInput {
|
|||||||
}
|
}
|
||||||
if !self.isECI(index as u32)? {
|
if !self.isECI(index as u32)? {
|
||||||
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||||
"value at {} is not an ECI but a character",
|
"value at {index} is not an ECI but a character"
|
||||||
index
|
|
||||||
))));
|
))));
|
||||||
}
|
}
|
||||||
Ok((self.bytes[index] as u32 - 256) as i32)
|
Ok((self.bytes[index] as u32 - 256) as i32)
|
||||||
@@ -352,7 +349,7 @@ impl MinimalECIInput {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if minimalJ < 0 {
|
if minimalJ < 0 {
|
||||||
panic!("internal error: failed to encode \"{}\"", stringToEncode);
|
panic!("internal error: failed to encode \"{stringToEncode}\"");
|
||||||
}
|
}
|
||||||
let mut intsAL: Vec<u16> = Vec::new();
|
let mut intsAL: Vec<u16> = Vec::new();
|
||||||
let mut current = edges[inputLength][minimalJ as usize].clone();
|
let mut current = edges[inputLength][minimalJ as usize].clone();
|
||||||
@@ -508,6 +505,6 @@ impl fmt::Display for MinimalECIInput {
|
|||||||
result.push(self.charAt(i).unwrap());
|
result.push(self.charAt(i).unwrap());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
write!(f, "{}", result)
|
write!(f, "{result}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -398,13 +398,11 @@ public static void corrupt(int[] received, int howMany, Random random, int max)
|
|||||||
fn test_encode_decode_random(field: GenericGFRef, dataSize: usize, ecSize: usize) {
|
fn test_encode_decode_random(field: GenericGFRef, dataSize: usize, ecSize: usize) {
|
||||||
assert!(
|
assert!(
|
||||||
dataSize > 0 && dataSize <= field.getSize() - 3,
|
dataSize > 0 && dataSize <= field.getSize() - 3,
|
||||||
"Invalid data size for {}",
|
"Invalid data size for {field}"
|
||||||
field
|
|
||||||
);
|
);
|
||||||
assert!(
|
assert!(
|
||||||
ecSize > 0 && ecSize + dataSize <= field.getSize(),
|
ecSize > 0 && ecSize + dataSize <= field.getSize(),
|
||||||
"Invalid ECC size for {}",
|
"Invalid ECC size for {field}"
|
||||||
field
|
|
||||||
);
|
);
|
||||||
let mut encoder = ReedSolomonEncoder::new(field);
|
let mut encoder = ReedSolomonEncoder::new(field);
|
||||||
let mut message = vec![0; dataSize + ecSize];
|
let mut message = vec![0; dataSize + ecSize];
|
||||||
@@ -427,7 +425,7 @@ fn test_encode_decode_random(field: GenericGFRef, dataSize: usize, ecSize: usize
|
|||||||
message[0..dataWords.len()].clone_from_slice(&dataWords[..]);
|
message[0..dataWords.len()].clone_from_slice(&dataWords[..]);
|
||||||
//System.arraycopy(dataWords, 0, message, 0, dataWords.len());
|
//System.arraycopy(dataWords, 0, message, 0, dataWords.len());
|
||||||
if let Err(err) = encoder.encode(&mut message, ecWords.len()) {
|
if let Err(err) = encoder.encode(&mut message, ecWords.len()) {
|
||||||
panic!("{:#?}", err);
|
panic!("{err:#?}");
|
||||||
}
|
}
|
||||||
ecWords[0..ecSize].clone_from_slice(&message[dataSize..dataSize + ecSize]);
|
ecWords[0..ecSize].clone_from_slice(&message[dataSize..dataSize + ecSize]);
|
||||||
//System.arraycopy(message, dataSize, ecWords, 0, ecSize);
|
//System.arraycopy(message, dataSize, ecWords, 0, ecSize);
|
||||||
|
|||||||
@@ -319,7 +319,7 @@ impl fmt::Display for GenericGFPoly {
|
|||||||
result.push('a');
|
result.push('a');
|
||||||
} else {
|
} else {
|
||||||
result.push_str("a^");
|
result.push_str("a^");
|
||||||
result.push_str(&format!("{}", alpha_power));
|
result.push_str(&format!("{alpha_power}"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -328,11 +328,11 @@ impl fmt::Display for GenericGFPoly {
|
|||||||
result.push('x');
|
result.push('x');
|
||||||
} else {
|
} else {
|
||||||
result.push_str("x^");
|
result.push_str("x^");
|
||||||
result.push_str(&format!("{}", degree));
|
result.push_str(&format!("{degree}"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
write!(f, "{}", result)
|
write!(f, "{result}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -204,8 +204,7 @@ impl ReedSolomonDecoder {
|
|||||||
|
|
||||||
if r.getDegree() >= rLast.getDegree() {
|
if r.getDegree() >= rLast.getDegree() {
|
||||||
return Err(Exceptions::ReedSolomonException(Some(format!(
|
return Err(Exceptions::ReedSolomonException(Some(format!(
|
||||||
"Division algorithm failed to reduce polynomial? r: {}, rLast: {}",
|
"Division algorithm failed to reduce polynomial? r: {r}, rLast: {rLast}"
|
||||||
r, rLast
|
|
||||||
))));
|
))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,15 +67,13 @@ impl Writer for DataMatrixWriter {
|
|||||||
|
|
||||||
if format != &BarcodeFormat::DATA_MATRIX {
|
if format != &BarcodeFormat::DATA_MATRIX {
|
||||||
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||||
"Can only encode DATA_MATRIX, but got {:?}",
|
"Can only encode DATA_MATRIX, but got {format:?}"
|
||||||
format
|
|
||||||
))));
|
))));
|
||||||
}
|
}
|
||||||
|
|
||||||
if width < 0 || height < 0 {
|
if width < 0 || height < 0 {
|
||||||
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||||
"Requested dimensions can't be negative: {}x{}",
|
"Requested dimensions can't be negative: {width}x{height}"
|
||||||
width, height
|
|
||||||
))));
|
))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -218,7 +218,7 @@ fn decodeAsciiSegment(
|
|||||||
result.append_char('0');
|
result.append_char('0');
|
||||||
}
|
}
|
||||||
//result.append_char(char::from_u32(value).unwrap());
|
//result.append_char(char::from_u32(value).unwrap());
|
||||||
result.append_string(&format!("{}", value));
|
result.append_string(&format!("{value}"));
|
||||||
} else {
|
} else {
|
||||||
match oneByte {
|
match oneByte {
|
||||||
230=> // Latch to C40 encodation
|
230=> // Latch to C40 encodation
|
||||||
|
|||||||
@@ -74,8 +74,7 @@ impl Encoder for ASCIIEncoder {
|
|||||||
|
|
||||||
_ => {
|
_ => {
|
||||||
return Err(Exceptions::IllegalStateException(Some(format!(
|
return Err(Exceptions::IllegalStateException(Some(format!(
|
||||||
"Illegal mode: {}",
|
"Illegal mode: {newMode}"
|
||||||
newMode
|
|
||||||
))));
|
))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -106,8 +105,7 @@ impl ASCIIEncoder {
|
|||||||
Ok((num + 130) as char)
|
Ok((num + 130) as char)
|
||||||
} else {
|
} else {
|
||||||
Err(Exceptions::IllegalArgumentException(Some(format!(
|
Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||||
"not digits: {}{}",
|
"not digits: {digit1}{digit2}"
|
||||||
digit1, digit2
|
|
||||||
))))
|
))))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,8 +66,7 @@ impl Encoder for Base256Encoder {
|
|||||||
buffer.insert(ci_pos, char::from_u32(dataCount as u32 % 250).unwrap());
|
buffer.insert(ci_pos, char::from_u32(dataCount as u32 % 250).unwrap());
|
||||||
} else {
|
} else {
|
||||||
return Err(Exceptions::IllegalStateException(Some(format!(
|
return Err(Exceptions::IllegalStateException(Some(format!(
|
||||||
"Message length not in valid ranges: {}",
|
"Message length not in valid ranges: {dataCount}"
|
||||||
dataCount
|
|
||||||
))));
|
))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -275,7 +275,7 @@ mod test_placement {
|
|||||||
let actual = placement.toBitFieldStringArray();
|
let actual = placement.toBitFieldStringArray();
|
||||||
for i in 0..actual.len() {
|
for i in 0..actual.len() {
|
||||||
// for (int i = 0; i < actual.length; i++) {
|
// for (int i = 0; i < actual.length; i++) {
|
||||||
assert_eq!(expected[i], actual[i], "Row {}", i);
|
assert_eq!(expected[i], actual[i], "Row {i}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -221,8 +221,7 @@ fn createECCBlock(codewords: &str, numECWords: usize) -> Result<String, Exceptio
|
|||||||
}
|
}
|
||||||
if table < 0 {
|
if table < 0 {
|
||||||
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||||
"Illegal number of error correction codewords specified: {}",
|
"Illegal number of error correction codewords specified: {numECWords}"
|
||||||
numECWords
|
|
||||||
))));
|
))));
|
||||||
}
|
}
|
||||||
let poly = &FACTORS[table as usize];
|
let poly = &FACTORS[table as usize];
|
||||||
|
|||||||
@@ -603,7 +603,6 @@ pub fn illegalCharacter(c: char) -> Result<(), Exceptions> {
|
|||||||
// let hex = Integer.toHexString(c);
|
// let hex = Integer.toHexString(c);
|
||||||
// hex = "0000".substring(0, 4 - hex.length()) + hex;
|
// hex = "0000".substring(0, 4 - hex.length()) + hex;
|
||||||
Err(Exceptions::IllegalArgumentException(Some(format!(
|
Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||||
"Illegal character: {} (0x{})",
|
"Illegal character: {c} (0x{c})"
|
||||||
c, c
|
|
||||||
))))
|
))))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -640,8 +640,7 @@ fn encodeMinimally(input: Rc<Input>) -> Result<RXingResult, Exceptions> {
|
|||||||
|
|
||||||
if minimalJ < 0 {
|
if minimalJ < 0 {
|
||||||
return Err(Exceptions::IllegalStateException(Some(format!(
|
return Err(Exceptions::IllegalStateException(Some(format!(
|
||||||
"Internal error: failed to encode \"{}\"",
|
"Internal error: failed to encode \"{input}\""
|
||||||
input
|
|
||||||
))));
|
))));
|
||||||
}
|
}
|
||||||
RXingResult::new(edges[inputLength][minimalJ as usize].clone())
|
RXingResult::new(edges[inputLength][minimalJ as usize].clone())
|
||||||
|
|||||||
@@ -346,8 +346,7 @@ impl<'a> SymbolInfoLookup<'a> {
|
|||||||
}
|
}
|
||||||
if fail {
|
if fail {
|
||||||
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||||
"Can't find a symbol arrangement that matches the message. Data codewords: {}",
|
"Can't find a symbol arrangement that matches the message. Data codewords: {dataCodewords}"
|
||||||
dataCodewords
|
|
||||||
))));
|
))));
|
||||||
}
|
}
|
||||||
Ok(None)
|
Ok(None)
|
||||||
|
|||||||
@@ -22,29 +22,29 @@ impl fmt::Display for Exceptions {
|
|||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
match self {
|
match self {
|
||||||
Exceptions::IllegalArgumentException(Some(a)) => {
|
Exceptions::IllegalArgumentException(Some(a)) => {
|
||||||
write!(f, "IllegalArgumentException - {}", a)
|
write!(f, "IllegalArgumentException - {a}")
|
||||||
}
|
}
|
||||||
|
|
||||||
Exceptions::UnsupportedOperationException(Some(a)) => {
|
Exceptions::UnsupportedOperationException(Some(a)) => {
|
||||||
write!(f, "UnsupportedOperationException - {}", a)
|
write!(f, "UnsupportedOperationException - {a}")
|
||||||
}
|
}
|
||||||
|
|
||||||
Exceptions::IllegalStateException(Some(a)) => {
|
Exceptions::IllegalStateException(Some(a)) => {
|
||||||
write!(f, "IllegalStateException - {}", a)
|
write!(f, "IllegalStateException - {a}")
|
||||||
}
|
}
|
||||||
Exceptions::ArithmeticException(Some(a)) => write!(f, "ArithmeticException - {}", a),
|
Exceptions::ArithmeticException(Some(a)) => write!(f, "ArithmeticException - {a}"),
|
||||||
Exceptions::NotFoundException(Some(a)) => write!(f, "NotFoundException - {}", a),
|
Exceptions::NotFoundException(Some(a)) => write!(f, "NotFoundException - {a}"),
|
||||||
Exceptions::FormatException(Some(a)) => write!(f, "FormatException - {}", a),
|
Exceptions::FormatException(Some(a)) => write!(f, "FormatException - {a}"),
|
||||||
Exceptions::ChecksumException(Some(a)) => write!(f, "ChecksumException - {}", a),
|
Exceptions::ChecksumException(Some(a)) => write!(f, "ChecksumException - {a}"),
|
||||||
Exceptions::ReaderException(Some(a)) => write!(f, "ReaderException - {}", a),
|
Exceptions::ReaderException(Some(a)) => write!(f, "ReaderException - {a}"),
|
||||||
Exceptions::WriterException(Some(a)) => write!(f, "WriterException - {}", a),
|
Exceptions::WriterException(Some(a)) => write!(f, "WriterException - {a}"),
|
||||||
Exceptions::ReedSolomonException(Some(a)) => write!(f, "ReedSolomonException - {}", a),
|
Exceptions::ReedSolomonException(Some(a)) => write!(f, "ReedSolomonException - {a}"),
|
||||||
Exceptions::IndexOutOfBoundsException(Some(a)) => {
|
Exceptions::IndexOutOfBoundsException(Some(a)) => {
|
||||||
write!(f, "IndexOutOfBoundsException - {}", a)
|
write!(f, "IndexOutOfBoundsException - {a}")
|
||||||
}
|
}
|
||||||
|
|
||||||
Exceptions::RuntimeException(Some(a)) => write!(f, "RuntimeException - {}", a),
|
Exceptions::RuntimeException(Some(a)) => write!(f, "RuntimeException - {a}"),
|
||||||
Exceptions::ParseException(Some(a)) => write!(f, "ParseException - {}", a),
|
Exceptions::ParseException(Some(a)) => write!(f, "ParseException - {a}"),
|
||||||
|
|
||||||
Exceptions::IllegalArgumentException(None) => write!(f, "IllegalArgumentException"),
|
Exceptions::IllegalArgumentException(None) => write!(f, "IllegalArgumentException"),
|
||||||
|
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ pub fn detect_in_file_with_hints(
|
|||||||
hints: &mut DecodingHintDictionary,
|
hints: &mut DecodingHintDictionary,
|
||||||
) -> Result<RXingResult, Exceptions> {
|
) -> Result<RXingResult, Exceptions> {
|
||||||
let Ok(img) = image::open(file_name) else {
|
let Ok(img) = image::open(file_name) else {
|
||||||
return Err(Exceptions::IllegalArgumentException(Some(format!("file '{}' not found or cannot be opened", file_name))));
|
return Err(Exceptions::IllegalArgumentException(Some(format!("file '{file_name}' not found or cannot be opened"))));
|
||||||
};
|
};
|
||||||
let mut multi_format_reader = MultiFormatReader::default();
|
let mut multi_format_reader = MultiFormatReader::default();
|
||||||
|
|
||||||
@@ -255,8 +255,7 @@ pub fn save_image(file_name: &str, bit_matrix: &BitMatrix) -> Result<(), Excepti
|
|||||||
match image.save(file_name) {
|
match image.save(file_name) {
|
||||||
Ok(_) => Ok(()),
|
Ok(_) => Ok(()),
|
||||||
Err(err) => Err(Exceptions::IllegalArgumentException(Some(format!(
|
Err(err) => Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||||
"could not save file '{}': {}",
|
"could not save file '{file_name}': {err}"
|
||||||
file_name, err
|
|
||||||
)))),
|
)))),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -303,8 +302,7 @@ pub fn save_file(file_name: &str, bit_matrix: &BitMatrix) -> Result<(), Exceptio
|
|||||||
}() {
|
}() {
|
||||||
Ok(_) => Ok(()),
|
Ok(_) => Ok(()),
|
||||||
Err(_) => Err(Exceptions::IllegalArgumentException(Some(format!(
|
Err(_) => Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||||
"could not write to '{}'",
|
"could not write to '{file_name}'"
|
||||||
file_name
|
|
||||||
)))),
|
)))),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,11 +61,8 @@ const POSTCODE_3_BYTES: [[u8; 6]; 6] = [
|
|||||||
|
|
||||||
static SETS: Lazy<[String; 5]> = Lazy::new(|| {
|
static SETS: Lazy<[String; 5]> = Lazy::new(|| {
|
||||||
[
|
[
|
||||||
format!("\rABCDEFGHIJKLMNOPQRSTUVWXYZ{}{}{}{}{} {}\"#$%&'()*+,-./0123456789:{}{}{}{}{}" , ECI , FS , GS , RS , NS , PAD ,
|
format!("\rABCDEFGHIJKLMNOPQRSTUVWXYZ{ECI}{FS}{GS}{RS}{NS} {PAD}\"#$%&'()*+,-./0123456789:{SHIFTB}{SHIFTC}{SHIFTD}{SHIFTE}{LATCHB}" ),
|
||||||
SHIFTB , SHIFTC , SHIFTD , SHIFTE , LATCHB),
|
format!("`abcdefghijklmnopqrstuvwxyz{ECI}{FS}{GS}{RS}{NS}{{{PAD}}}~\u{007F};<=>?[\\]^_ ,./:@!|{PAD}{TWOSHIFTA}{THREESHIFTA}{PAD}{SHIFTA}{SHIFTC}{SHIFTD}{SHIFTE}{LATCHA}" ),
|
||||||
format!("`abcdefghijklmnopqrstuvwxyz{}{}{}{}{}{{{}}}~\u{007F};<=>?[\\]^_ ,./:@!|{}{}{}{}{}{}{}{}{}" , ECI , FS , GS , RS , NS ,PAD ,
|
|
||||||
PAD , TWOSHIFTA , THREESHIFTA , PAD ,
|
|
||||||
SHIFTA , SHIFTC , SHIFTD , SHIFTE , LATCHA),
|
|
||||||
format!("\u{00C0}\u{00C1}\u{00C2}\u{00C3}\u{00C4}\u{00C5}\u{00C6}\u{00C7}\u{00C8}\u{00C9}\u{00CA}\u{00CB}\u{00CC}\u{00CD}\u{00CE}\u{00CF}\u{00D0}\u{00D1}\u{00D2}\u{00D3}\u{00D4}\u{00D5}\u{00D6}\u{00D7}\u{00D8}\u{00D9}\u{00DA}{}{}{}{}{}{}{}{}{}{}{}{}" ,
|
format!("\u{00C0}\u{00C1}\u{00C2}\u{00C3}\u{00C4}\u{00C5}\u{00C6}\u{00C7}\u{00C8}\u{00C9}\u{00CA}\u{00CB}\u{00CC}\u{00CD}\u{00CE}\u{00CF}\u{00D0}\u{00D1}\u{00D2}\u{00D3}\u{00D4}\u{00D5}\u{00D6}\u{00D7}\u{00D8}\u{00D9}\u{00DA}{}{}{}{}{}{}{}{}{}{}{}{}" ,
|
||||||
ECI , FS , GS , RS , NS ,
|
ECI , FS , GS , RS , NS ,
|
||||||
"\u{00DB}\u{00DC}\u{00DD}\u{00DE}\u{00DF}\u{00AA}\u{00AC}\u{00B1}\u{00B2}\u{00B3}\u{00B5}\u{00B9}\u{00BA}\u{00BC}\u{00BD}\u{00BE}\u{0080}\u{0081}\u{0082}\u{0083}\u{0084}\u{0085}\u{0086}\u{0087}\u{0088}\u{0089}" ,
|
"\u{00DB}\u{00DC}\u{00DD}\u{00DE}\u{00DF}\u{00AA}\u{00AC}\u{00B1}\u{00B2}\u{00B3}\u{00B5}\u{00B9}\u{00BA}\u{00BC}\u{00BD}\u{00BE}\u{0080}\u{0081}\u{0082}\u{0083}\u{0084}\u{0085}\u{0086}\u{0087}\u{0088}\u{0089}" ,
|
||||||
@@ -93,7 +90,7 @@ pub fn decode(bytes: &[u8], mode: u8) -> Result<DecoderRXingResult, Exceptions>
|
|||||||
}
|
}
|
||||||
// NumberFormat df = new DecimalFormat("0000000000".substring(0, ps2Length));
|
// NumberFormat df = new DecimalFormat("0000000000".substring(0, ps2Length));
|
||||||
// postcode = df.format(pc);
|
// postcode = df.format(pc);
|
||||||
format!("{:0>ps2Length$}", pc)
|
format!("{pc:0>ps2Length$}")
|
||||||
} else {
|
} else {
|
||||||
getPostCode3(bytes)
|
getPostCode3(bytes)
|
||||||
};
|
};
|
||||||
@@ -106,12 +103,12 @@ pub fn decode(bytes: &[u8], mode: u8) -> Result<DecoderRXingResult, Exceptions>
|
|||||||
if result.starts_with(&format!("[)>{}{}{}", RS, "01", GS)) {
|
if result.starts_with(&format!("[)>{}{}{}", RS, "01", GS)) {
|
||||||
result.insert_str(
|
result.insert_str(
|
||||||
9,
|
9,
|
||||||
&format!("{}{}{}{}{}{}", postcode, GS, country, GS, service, GS),
|
&format!("{postcode}{GS}{country}{GS}{service}{GS}"),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
result.insert_str(
|
result.insert_str(
|
||||||
0,
|
0,
|
||||||
&format!("{}{}{}{}{}{}", postcode, GS, country, GS, service, GS),
|
&format!("{postcode}{GS}{country}{GS}{service}{GS}"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -226,7 +223,7 @@ fn getMessage(bytes: &[u8], start: u32, len: u32) -> String {
|
|||||||
i += 1;
|
i += 1;
|
||||||
nsval += bytes[i as usize] as u32;
|
nsval += bytes[i as usize] as u32;
|
||||||
// sb.append(new DecimalFormat("000000000").format(nsval));},
|
// sb.append(new DecimalFormat("000000000").format(nsval));},
|
||||||
sb.push_str(&format!("{:0>9}", nsval));
|
sb.push_str(&format!("{nsval:0>9}"));
|
||||||
}
|
}
|
||||||
LOCK => {
|
LOCK => {
|
||||||
shift = -1;
|
shift = -1;
|
||||||
|
|||||||
@@ -140,11 +140,12 @@ impl<'a> Circle<'_> {
|
|||||||
// find semi-major and semi-minor axi
|
// find semi-major and semi-minor axi
|
||||||
let mut lengths = [(0, 0.0, [(0.0_f32, 0.0); 2]); 72];
|
let mut lengths = [(0, 0.0, [(0.0_f32, 0.0); 2]); 72];
|
||||||
let mut circle_points = Vec::new();
|
let mut circle_points = Vec::new();
|
||||||
for i_rotation in 0..72 {
|
// for i_rotation in 0..72 {
|
||||||
|
for (i_rotation, length_set) in lengths.iter_mut().enumerate(){
|
||||||
let rotation = i_rotation as f32 * 5.0;
|
let rotation = i_rotation as f32 * 5.0;
|
||||||
let (length, points) = self.find_width_at_degree(rotation);
|
let (length, points) = self.find_width_at_degree(rotation);
|
||||||
circle_points.extend_from_slice(&points);
|
circle_points.extend_from_slice(&points);
|
||||||
lengths[i_rotation] = (length, rotation, points);
|
*length_set = (length, rotation, points);
|
||||||
}
|
}
|
||||||
lengths.sort_by_key(|e| e.0);
|
lengths.sort_by_key(|e| e.0);
|
||||||
let major_axis = lengths.last().unwrap();
|
let major_axis = lengths.last().unwrap();
|
||||||
@@ -352,12 +353,12 @@ pub fn detect(image: &BitMatrix, try_harder: bool) -> Result<MaxicodeDetectionRe
|
|||||||
target_height.round() as u32,
|
target_height.round() as u32,
|
||||||
0.0,
|
0.0,
|
||||||
0.0,
|
0.0,
|
||||||
target_width as f32 ,
|
target_width ,
|
||||||
0.0,
|
0.0,
|
||||||
target_width as f32,
|
target_width,
|
||||||
target_height as f32,
|
target_height,
|
||||||
0.0,
|
0.0,
|
||||||
target_height as f32,
|
target_height,
|
||||||
tl.0,
|
tl.0,
|
||||||
tl.1,
|
tl.1,
|
||||||
tr.0,
|
tr.0,
|
||||||
|
|||||||
@@ -72,8 +72,7 @@ impl Writer for MultiFormatWriter {
|
|||||||
BarcodeFormat::AZTEC => Box::<AztecWriter>::default(),
|
BarcodeFormat::AZTEC => Box::<AztecWriter>::default(),
|
||||||
_ => {
|
_ => {
|
||||||
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||||
"No encoder available for format {:?}",
|
"No encoder available for format {format:?}"
|
||||||
format
|
|
||||||
))))
|
))))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ impl OneDimensionalCodeWriter for CodaBarWriter {
|
|||||||
fn encode_oned(&self, contents: &str) -> Result<Vec<bool>, crate::Exceptions> {
|
fn encode_oned(&self, contents: &str) -> Result<Vec<bool>, crate::Exceptions> {
|
||||||
let contents = if contents.chars().count() < 2 {
|
let contents = if contents.chars().count() < 2 {
|
||||||
// Can't have a start/end guard, so tentatively add default guards
|
// Can't have a start/end guard, so tentatively add default guards
|
||||||
format!("{}{}{}", DEFAULT_GUARD, contents, DEFAULT_GUARD)
|
format!("{DEFAULT_GUARD}{contents}{DEFAULT_GUARD}")
|
||||||
} else {
|
} else {
|
||||||
// Verify input and calculate decoded length.
|
// Verify input and calculate decoded length.
|
||||||
let firstChar = contents.chars().next().unwrap().to_ascii_uppercase();
|
let firstChar = contents.chars().next().unwrap().to_ascii_uppercase();
|
||||||
@@ -53,8 +53,7 @@ impl OneDimensionalCodeWriter for CodaBarWriter {
|
|||||||
if startsNormal {
|
if startsNormal {
|
||||||
if !endsNormal {
|
if !endsNormal {
|
||||||
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||||
"Invalid start/end guards: {}",
|
"Invalid start/end guards: {contents}"
|
||||||
contents
|
|
||||||
))));
|
))));
|
||||||
}
|
}
|
||||||
// else already has valid start/end
|
// else already has valid start/end
|
||||||
@@ -62,8 +61,7 @@ impl OneDimensionalCodeWriter for CodaBarWriter {
|
|||||||
} else if startsAlt {
|
} else if startsAlt {
|
||||||
if !endsAlt {
|
if !endsAlt {
|
||||||
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||||
"Invalid start/end guards: {}",
|
"Invalid start/end guards: {contents}"
|
||||||
contents
|
|
||||||
))));
|
))));
|
||||||
}
|
}
|
||||||
// else already has valid start/end
|
// else already has valid start/end
|
||||||
@@ -72,12 +70,11 @@ impl OneDimensionalCodeWriter for CodaBarWriter {
|
|||||||
// Doesn't start with a guard
|
// Doesn't start with a guard
|
||||||
if endsNormal || endsAlt {
|
if endsNormal || endsAlt {
|
||||||
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||||
"Invalid start/end guards: {}",
|
"Invalid start/end guards: {contents}"
|
||||||
contents
|
|
||||||
))));
|
))));
|
||||||
}
|
}
|
||||||
// else doesn't end with guard either, so add a default
|
// else doesn't end with guard either, so add a default
|
||||||
format!("{}{}{}", DEFAULT_GUARD, contents, DEFAULT_GUARD)
|
format!("{DEFAULT_GUARD}{contents}{DEFAULT_GUARD}")
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -95,8 +92,7 @@ impl OneDimensionalCodeWriter for CodaBarWriter {
|
|||||||
resultLength += 10;
|
resultLength += 10;
|
||||||
} else {
|
} else {
|
||||||
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||||
"Cannot encode : '{}'",
|
"Cannot encode : '{ch}'"
|
||||||
ch
|
|
||||||
))));
|
))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -356,7 +356,7 @@ impl OneDReader for Code128Reader {
|
|||||||
|
|
||||||
resultObject.putMetadata(
|
resultObject.putMetadata(
|
||||||
RXingResultMetadataType::SYMBOLOGY_IDENTIFIER,
|
RXingResultMetadataType::SYMBOLOGY_IDENTIFIER,
|
||||||
RXingResultMetadataValue::SymbologyIdentifier(format!("]C{}", symbologyModifier)),
|
RXingResultMetadataValue::SymbologyIdentifier(format!("]C{symbologyModifier}")),
|
||||||
);
|
);
|
||||||
|
|
||||||
Ok(resultObject)
|
Ok(resultObject)
|
||||||
|
|||||||
@@ -96,8 +96,7 @@ fn check(contents: &str, hints: &crate::EncodingHintDictionary) -> Result<i32, E
|
|||||||
// Check length
|
// Check length
|
||||||
if !(1..=80).contains(&length) {
|
if !(1..=80).contains(&length) {
|
||||||
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||||
"Contents length should be between 1 and 80 characters, but got {}",
|
"Contents length should be between 1 and 80 characters, but got {length}"
|
||||||
length
|
|
||||||
))));
|
))));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,8 +110,7 @@ fn check(contents: &str, hints: &crate::EncodingHintDictionary) -> Result<i32, E
|
|||||||
"C" => forcedCodeSet = CODE_CODE_C as i32,
|
"C" => forcedCodeSet = CODE_CODE_C as i32,
|
||||||
_ => {
|
_ => {
|
||||||
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||||
"Unsupported code set hint: {}",
|
"Unsupported code set hint: {codeSetHint}"
|
||||||
codeSetHint
|
|
||||||
))))
|
))))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -133,8 +131,7 @@ fn check(contents: &str, hints: &crate::EncodingHintDictionary) -> Result<i32, E
|
|||||||
// no full Latin-1 character set available at the moment
|
// no full Latin-1 character set available at the moment
|
||||||
// shift and manual code change are not supported
|
// shift and manual code change are not supported
|
||||||
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||||
"Bad character in input: ASCII value={}",
|
"Bad character in input: ASCII value={c}"
|
||||||
c
|
|
||||||
))));
|
))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -149,8 +146,7 @@ fn check(contents: &str, hints: &crate::EncodingHintDictionary) -> Result<i32, E
|
|||||||
{
|
{
|
||||||
if c > 95 && c <= 127 {
|
if c > 95 && c <= 127 {
|
||||||
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||||
"Bad character in input for forced code set A: ASCII value={}",
|
"Bad character in input for forced code set A: ASCII value={c}"
|
||||||
c
|
|
||||||
))));
|
))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -159,8 +155,7 @@ fn check(contents: &str, hints: &crate::EncodingHintDictionary) -> Result<i32, E
|
|||||||
{
|
{
|
||||||
if c <= 32 {
|
if c <= 32 {
|
||||||
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||||
"Bad character in input for forced code set B: ASCII value={}",
|
"Bad character in input for forced code set B: ASCII value={c}"
|
||||||
c
|
|
||||||
))));
|
))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -174,8 +169,7 @@ fn check(contents: &str, hints: &crate::EncodingHintDictionary) -> Result<i32, E
|
|||||||
|| ch == ESCAPE_FNC_4
|
|| ch == ESCAPE_FNC_4
|
||||||
{
|
{
|
||||||
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||||
"Bad character in input for forced code set C: ASCII value={}",
|
"Bad character in input for forced code set C: ASCII value={c}"
|
||||||
c
|
|
||||||
))));
|
))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -311,7 +311,7 @@ fn testEncodeSwitchBetweenCodesetsAAndB() {
|
|||||||
fn testEncode(toEncode: &str, expected: &str) {
|
fn testEncode(toEncode: &str, expected: &str) {
|
||||||
let result = encode(toEncode, false, toEncode).expect("encode");
|
let result = encode(toEncode, false, toEncode).expect("encode");
|
||||||
let actual = bit_matrix_test_case::matrix_to_string(&result);
|
let actual = bit_matrix_test_case::matrix_to_string(&result);
|
||||||
assert_eq!(expected, actual, "{}", toEncode);
|
assert_eq!(expected, actual, "{toEncode}");
|
||||||
|
|
||||||
let width = result.getWidth();
|
let width = result.getWidth();
|
||||||
let result = encode(toEncode, true, toEncode).expect("encode");
|
let result = encode(toEncode, true, toEncode).expect("encode");
|
||||||
|
|||||||
@@ -34,8 +34,7 @@ impl OneDimensionalCodeWriter for Code39Writer {
|
|||||||
let mut length = contents.chars().count();
|
let mut length = contents.chars().count();
|
||||||
if length > 80 {
|
if length > 80 {
|
||||||
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||||
"Requested contents should be less than 80 digits long, but got {}",
|
"Requested contents should be less than 80 digits long, but got {length}"
|
||||||
length
|
|
||||||
))));
|
))));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,7 +49,7 @@ impl OneDimensionalCodeWriter for Code39Writer {
|
|||||||
contents = Self::tryToConvertToExtendedMode(&contents)?;
|
contents = Self::tryToConvertToExtendedMode(&contents)?;
|
||||||
length = contents.chars().count();
|
length = contents.chars().count();
|
||||||
if length > 80 {
|
if length > 80 {
|
||||||
return Err(Exceptions::IllegalArgumentException(Some(format!("Requested contents should be less than 80 digits long, but got {} (extended full ASCII mode)",length))));
|
return Err(Exceptions::IllegalArgumentException(Some(format!("Requested contents should be less than 80 digits long, but got {length} (extended full ASCII mode)"))));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -156,8 +155,7 @@ impl Code39Writer {
|
|||||||
.push(char::from_u32('P' as u32 + (character as u32 - 123)).unwrap());
|
.push(char::from_u32('P' as u32 + (character as u32 - 123)).unwrap());
|
||||||
} else {
|
} else {
|
||||||
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||||
"Requested content contains a non-encodable character: '{}'",
|
"Requested content contains a non-encodable character: '{character}'"
|
||||||
character
|
|
||||||
))));
|
))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -249,8 +247,7 @@ mod Code39WriterTestCase {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
expected,
|
expected,
|
||||||
bit_matrix_test_case::matrix_to_string(&result),
|
bit_matrix_test_case::matrix_to_string(&result),
|
||||||
"{}",
|
"{input}"
|
||||||
input
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ impl OneDimensionalCodeWriter for Code93Writer {
|
|||||||
let mut contents = Self::convertToExtended(contents)?;
|
let mut contents = Self::convertToExtended(contents)?;
|
||||||
let length = contents.chars().count();
|
let length = contents.chars().count();
|
||||||
if length > 80 {
|
if length > 80 {
|
||||||
return Err(Exceptions::IllegalArgumentException(Some(format!("Requested contents should be less than 80 digits long after converting to extended encoding, but got {}" , length))));
|
return Err(Exceptions::IllegalArgumentException(Some(format!("Requested contents should be less than 80 digits long after converting to extended encoding, but got {length}" ))));
|
||||||
}
|
}
|
||||||
|
|
||||||
//length of code + 2 start/stop characters + 2 checksums, each of 9 bits, plus a termination bar
|
//length of code + 2 start/stop characters + 2 checksums, each of 9 bits, plus a termination bar
|
||||||
@@ -197,8 +197,7 @@ impl Code93Writer {
|
|||||||
.push(char::from_u32('P' as u32 + character as u32 - '{' as u32).unwrap());
|
.push(char::from_u32('P' as u32 + character as u32 - '{' as u32).unwrap());
|
||||||
} else {
|
} else {
|
||||||
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||||
"Requested content contains a non-encodable character: '{}'",
|
"Requested content contains a non-encodable character: '{character}'"
|
||||||
character
|
|
||||||
))));
|
))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,8 +61,7 @@ impl OneDimensionalCodeWriter for EAN13Writer {
|
|||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||||
"Requested contents should be 12 or 13 digits long, but got {}",
|
"Requested contents should be 12 or 13 digits long, but got {length}"
|
||||||
length
|
|
||||||
))))
|
))))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,8 +71,7 @@ impl OneDimensionalCodeWriter for EAN8Writer {
|
|||||||
// }},
|
// }},
|
||||||
_ => {
|
_ => {
|
||||||
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||||
"Requested contents should be 7 or 8 digits long, but got {}",
|
"Requested contents should be 7 or 8 digits long, but got {length}"
|
||||||
length
|
|
||||||
))))
|
))))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,8 +38,7 @@ impl OneDimensionalCodeWriter for ITFWriter {
|
|||||||
}
|
}
|
||||||
if length > 80 {
|
if length > 80 {
|
||||||
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||||
"Requested contents should be less than 80 digits long, but got {}",
|
"Requested contents should be less than 80 digits long, but got {length}"
|
||||||
length
|
|
||||||
))));
|
))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -173,15 +173,13 @@ impl Writer for L {
|
|||||||
|
|
||||||
if width < 0 || height < 0 {
|
if width < 0 || height < 0 {
|
||||||
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||||
"Negative size is not allowed. Input: {}x{}",
|
"Negative size is not allowed. Input: {width}x{height}"
|
||||||
width, height
|
|
||||||
))));
|
))));
|
||||||
}
|
}
|
||||||
if let Some(supportedFormats) = self.getSupportedWriteFormats() {
|
if let Some(supportedFormats) = self.getSupportedWriteFormats() {
|
||||||
if !supportedFormats.contains(format) {
|
if !supportedFormats.contains(format) {
|
||||||
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||||
"Can only encode {:?}, but got {:?}",
|
"Can only encode {supportedFormats:?}, but got {format:?}"
|
||||||
supportedFormats, format
|
|
||||||
))));
|
))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -150,7 +150,6 @@ pub fn createDecoder<'a>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
Err(Exceptions::IllegalStateException(Some(format!(
|
Err(Exceptions::IllegalStateException(Some(format!(
|
||||||
"unknown decoder: {}",
|
"unknown decoder: {information}"
|
||||||
information
|
|
||||||
))))
|
))))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,8 +83,7 @@ mod AI013103DecoderTest {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test0131031() {
|
fn test0131031() {
|
||||||
let data = format!(
|
let data = format!(
|
||||||
"{}{}{}",
|
"{HEADER}{COMPRESSED_GTIN900123456798908}{COMPRESSED15BIT_WEIGHT1750}"
|
||||||
HEADER, COMPRESSED_GTIN900123456798908, COMPRESSED15BIT_WEIGHT1750
|
|
||||||
);
|
);
|
||||||
let expected = "(01)90012345678908(3103)001750";
|
let expected = "(01)90012345678908(3103)001750";
|
||||||
assertCorrectBinaryString(&data, expected);
|
assertCorrectBinaryString(&data, expected);
|
||||||
@@ -93,8 +92,7 @@ mod AI013103DecoderTest {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test0131032() {
|
fn test0131032() {
|
||||||
let data = format!(
|
let data = format!(
|
||||||
"{}{}{}",
|
"{HEADER}{COMPRESSED_GTIN900000000000008}{COMPRESSED15BIT_WEIGHT0}"
|
||||||
HEADER, COMPRESSED_GTIN900000000000008, COMPRESSED15BIT_WEIGHT0
|
|
||||||
);
|
);
|
||||||
let expected = "(01)90000000000003(3103)000000";
|
let expected = "(01)90000000000003(3103)000000";
|
||||||
assertCorrectBinaryString(&data, expected);
|
assertCorrectBinaryString(&data, expected);
|
||||||
@@ -104,8 +102,7 @@ mod AI013103DecoderTest {
|
|||||||
#[should_panic]
|
#[should_panic]
|
||||||
fn test013103invalid() {
|
fn test013103invalid() {
|
||||||
let data = format!(
|
let data = format!(
|
||||||
"{}{}{}..",
|
"{HEADER}{COMPRESSED_GTIN900123456798908}{COMPRESSED15BIT_WEIGHT1750}.."
|
||||||
HEADER, COMPRESSED_GTIN900123456798908, COMPRESSED15BIT_WEIGHT1750
|
|
||||||
);
|
);
|
||||||
assertCorrectBinaryString(&data, "");
|
assertCorrectBinaryString(&data, "");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,8 +35,7 @@ const HEADER: &str = "..X.X";
|
|||||||
#[test]
|
#[test]
|
||||||
fn test0132021() {
|
fn test0132021() {
|
||||||
let data = format!(
|
let data = format!(
|
||||||
"{}{}{}",
|
"{HEADER}{COMPRESSED_GTIN900123456798908}{COMPRESSED15BIT_WEIGHT1750}"
|
||||||
HEADER, COMPRESSED_GTIN900123456798908, COMPRESSED15BIT_WEIGHT1750
|
|
||||||
);
|
);
|
||||||
let expected = "(01)90012345678908(3202)001750";
|
let expected = "(01)90012345678908(3202)001750";
|
||||||
|
|
||||||
@@ -46,8 +45,7 @@ fn test0132021() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test0132031() {
|
fn test0132031() {
|
||||||
let data = format!(
|
let data = format!(
|
||||||
"{}{}{}",
|
"{HEADER}{COMPRESSED_GTIN900123456798908}{COMPRESSED15BIT_WEIGHT11750}"
|
||||||
HEADER, COMPRESSED_GTIN900123456798908, COMPRESSED15BIT_WEIGHT11750
|
|
||||||
);
|
);
|
||||||
let expected = "(01)90012345678908(3203)001750";
|
let expected = "(01)90012345678908(3203)001750";
|
||||||
|
|
||||||
|
|||||||
@@ -151,11 +151,7 @@ mod AI013X0X1XDecoderTest {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test01310X1XendDate() {
|
fn test01310X1XendDate() {
|
||||||
let data = format!(
|
let data = format!(
|
||||||
"{}{}{}{}",
|
"{HEADER310X11}{COMPRESSED_GTIN900123456798908}{COMPRESSED20BIT_WEIGHT1750}{COMPRESSED_DATE_END}"
|
||||||
HEADER310X11,
|
|
||||||
COMPRESSED_GTIN900123456798908,
|
|
||||||
COMPRESSED20BIT_WEIGHT1750,
|
|
||||||
COMPRESSED_DATE_END
|
|
||||||
);
|
);
|
||||||
let expected = "(01)90012345678908(3100)001750";
|
let expected = "(01)90012345678908(3100)001750";
|
||||||
|
|
||||||
@@ -165,11 +161,7 @@ mod AI013X0X1XDecoderTest {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test01310X111() {
|
fn test01310X111() {
|
||||||
let data = format!(
|
let data = format!(
|
||||||
"{}{}{}{}",
|
"{HEADER310X11}{COMPRESSED_GTIN900123456798908}{COMPRESSED20BIT_WEIGHT1750}{COMPRESSED_DATE_MARCH12TH2010}"
|
||||||
HEADER310X11,
|
|
||||||
COMPRESSED_GTIN900123456798908,
|
|
||||||
COMPRESSED20BIT_WEIGHT1750,
|
|
||||||
COMPRESSED_DATE_MARCH12TH2010
|
|
||||||
);
|
);
|
||||||
let expected = "(01)90012345678908(3100)001750(11)100312";
|
let expected = "(01)90012345678908(3100)001750(11)100312";
|
||||||
|
|
||||||
@@ -179,11 +171,7 @@ mod AI013X0X1XDecoderTest {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test01320X111() {
|
fn test01320X111() {
|
||||||
let data = format!(
|
let data = format!(
|
||||||
"{}{}{}{}",
|
"{HEADER320X11}{COMPRESSED_GTIN900123456798908}{COMPRESSED20BIT_WEIGHT1750}{COMPRESSED_DATE_MARCH12TH2010}"
|
||||||
HEADER320X11,
|
|
||||||
COMPRESSED_GTIN900123456798908,
|
|
||||||
COMPRESSED20BIT_WEIGHT1750,
|
|
||||||
COMPRESSED_DATE_MARCH12TH2010
|
|
||||||
);
|
);
|
||||||
let expected = "(01)90012345678908(3200)001750(11)100312";
|
let expected = "(01)90012345678908(3200)001750(11)100312";
|
||||||
|
|
||||||
@@ -193,11 +181,7 @@ mod AI013X0X1XDecoderTest {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test01310X131() {
|
fn test01310X131() {
|
||||||
let data = format!(
|
let data = format!(
|
||||||
"{}{}{}{}",
|
"{HEADER310X13}{COMPRESSED_GTIN900123456798908}{COMPRESSED20BIT_WEIGHT1750}{COMPRESSED_DATE_MARCH12TH2010}"
|
||||||
HEADER310X13,
|
|
||||||
COMPRESSED_GTIN900123456798908,
|
|
||||||
COMPRESSED20BIT_WEIGHT1750,
|
|
||||||
COMPRESSED_DATE_MARCH12TH2010
|
|
||||||
);
|
);
|
||||||
let expected = "(01)90012345678908(3100)001750(13)100312";
|
let expected = "(01)90012345678908(3100)001750(13)100312";
|
||||||
|
|
||||||
@@ -207,11 +191,7 @@ mod AI013X0X1XDecoderTest {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test01320X131() {
|
fn test01320X131() {
|
||||||
let data = format!(
|
let data = format!(
|
||||||
"{}{}{}{}",
|
"{HEADER320X13}{COMPRESSED_GTIN900123456798908}{COMPRESSED20BIT_WEIGHT1750}{COMPRESSED_DATE_MARCH12TH2010}"
|
||||||
HEADER320X13,
|
|
||||||
COMPRESSED_GTIN900123456798908,
|
|
||||||
COMPRESSED20BIT_WEIGHT1750,
|
|
||||||
COMPRESSED_DATE_MARCH12TH2010
|
|
||||||
);
|
);
|
||||||
let expected = "(01)90012345678908(3200)001750(13)100312";
|
let expected = "(01)90012345678908(3200)001750(13)100312";
|
||||||
|
|
||||||
@@ -221,11 +201,7 @@ mod AI013X0X1XDecoderTest {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test01310X151() {
|
fn test01310X151() {
|
||||||
let data = format!(
|
let data = format!(
|
||||||
"{}{}{}{}",
|
"{HEADER310X15}{COMPRESSED_GTIN900123456798908}{COMPRESSED20BIT_WEIGHT1750}{COMPRESSED_DATE_MARCH12TH2010}"
|
||||||
HEADER310X15,
|
|
||||||
COMPRESSED_GTIN900123456798908,
|
|
||||||
COMPRESSED20BIT_WEIGHT1750,
|
|
||||||
COMPRESSED_DATE_MARCH12TH2010
|
|
||||||
);
|
);
|
||||||
let expected = "(01)90012345678908(3100)001750(15)100312";
|
let expected = "(01)90012345678908(3100)001750(15)100312";
|
||||||
|
|
||||||
@@ -235,11 +211,7 @@ mod AI013X0X1XDecoderTest {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test01320X151() {
|
fn test01320X151() {
|
||||||
let data = format!(
|
let data = format!(
|
||||||
"{}{}{}{}",
|
"{HEADER320X15}{COMPRESSED_GTIN900123456798908}{COMPRESSED20BIT_WEIGHT1750}{COMPRESSED_DATE_MARCH12TH2010}"
|
||||||
HEADER320X15,
|
|
||||||
COMPRESSED_GTIN900123456798908,
|
|
||||||
COMPRESSED20BIT_WEIGHT1750,
|
|
||||||
COMPRESSED_DATE_MARCH12TH2010
|
|
||||||
);
|
);
|
||||||
let expected = "(01)90012345678908(3200)001750(15)100312";
|
let expected = "(01)90012345678908(3200)001750(15)100312";
|
||||||
|
|
||||||
@@ -249,11 +221,7 @@ mod AI013X0X1XDecoderTest {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test01310X171() {
|
fn test01310X171() {
|
||||||
let data = format!(
|
let data = format!(
|
||||||
"{}{}{}{}",
|
"{HEADER310X17}{COMPRESSED_GTIN900123456798908}{COMPRESSED20BIT_WEIGHT1750}{COMPRESSED_DATE_MARCH12TH2010}"
|
||||||
HEADER310X17,
|
|
||||||
COMPRESSED_GTIN900123456798908,
|
|
||||||
COMPRESSED20BIT_WEIGHT1750,
|
|
||||||
COMPRESSED_DATE_MARCH12TH2010
|
|
||||||
);
|
);
|
||||||
let expected = "(01)90012345678908(3100)001750(17)100312";
|
let expected = "(01)90012345678908(3100)001750(17)100312";
|
||||||
|
|
||||||
@@ -263,11 +231,7 @@ mod AI013X0X1XDecoderTest {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test01320X171() {
|
fn test01320X171() {
|
||||||
let data = format!(
|
let data = format!(
|
||||||
"{}{}{}{}",
|
"{HEADER320X17}{COMPRESSED_GTIN900123456798908}{COMPRESSED20BIT_WEIGHT1750}{COMPRESSED_DATE_MARCH12TH2010}"
|
||||||
HEADER320X17,
|
|
||||||
COMPRESSED_GTIN900123456798908,
|
|
||||||
COMPRESSED20BIT_WEIGHT1750,
|
|
||||||
COMPRESSED_DATE_MARCH12TH2010
|
|
||||||
);
|
);
|
||||||
let expected = "(01)90012345678908(3200)001750(17)100312";
|
let expected = "(01)90012345678908(3200)001750(17)100312";
|
||||||
|
|
||||||
|
|||||||
@@ -70,8 +70,7 @@ mod AnyAIDecoderTest {
|
|||||||
#[test]
|
#[test]
|
||||||
fn testAnyAIDecoder1() {
|
fn testAnyAIDecoder1() {
|
||||||
let data = format!(
|
let data = format!(
|
||||||
"{}{}{}{}{}{}{}",
|
"{HEADER}{NUMERIC10}{NUMERIC12}{NUMERIC2ALPHA}{ALPHA_A}{ALPHA2NUMERIC}{NUMERIC12}"
|
||||||
HEADER, NUMERIC10, NUMERIC12, NUMERIC2ALPHA, ALPHA_A, ALPHA2NUMERIC, NUMERIC12
|
|
||||||
);
|
);
|
||||||
let expected = "(10)12A12";
|
let expected = "(10)12A12";
|
||||||
|
|
||||||
@@ -81,8 +80,7 @@ mod AnyAIDecoderTest {
|
|||||||
#[test]
|
#[test]
|
||||||
fn testAnyAIDecoder2() {
|
fn testAnyAIDecoder2() {
|
||||||
let data = format!(
|
let data = format!(
|
||||||
"{}{}{}{}{}{}{}",
|
"{HEADER}{NUMERIC10}{NUMERIC12}{NUMERIC2ALPHA}{ALPHA_A}{ALPHA2ISOIEC646}{I646_B}"
|
||||||
HEADER, NUMERIC10, NUMERIC12, NUMERIC2ALPHA, ALPHA_A, ALPHA2ISOIEC646, I646_B
|
|
||||||
);
|
);
|
||||||
let expected = "(10)12AB";
|
let expected = "(10)12AB";
|
||||||
|
|
||||||
@@ -92,17 +90,7 @@ mod AnyAIDecoderTest {
|
|||||||
#[test]
|
#[test]
|
||||||
fn testAnyAIDecoder3() {
|
fn testAnyAIDecoder3() {
|
||||||
let data = format!(
|
let data = format!(
|
||||||
"{}{}{}{}{}{}{}{}{}{}",
|
"{HEADER}{NUMERIC10}{NUMERIC2ALPHA}{ALPHA2ISOIEC646}{I646_B}{I646_C}{ISOIEC6462ALPHA}{ALPHA_A}{ALPHA2NUMERIC}{NUMERIC10}"
|
||||||
HEADER,
|
|
||||||
NUMERIC10,
|
|
||||||
NUMERIC2ALPHA,
|
|
||||||
ALPHA2ISOIEC646,
|
|
||||||
I646_B,
|
|
||||||
I646_C,
|
|
||||||
ISOIEC6462ALPHA,
|
|
||||||
ALPHA_A,
|
|
||||||
ALPHA2NUMERIC,
|
|
||||||
NUMERIC10
|
|
||||||
);
|
);
|
||||||
let expected = "(10)BCA10";
|
let expected = "(10)BCA10";
|
||||||
|
|
||||||
@@ -111,7 +99,7 @@ mod AnyAIDecoderTest {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn testAnyAIDecodernumericFNC1secondDigit() {
|
fn testAnyAIDecodernumericFNC1secondDigit() {
|
||||||
let data = format!("{}{}{}", HEADER, NUMERIC10, NUMERIC1_FNC1);
|
let data = format!("{HEADER}{NUMERIC10}{NUMERIC1_FNC1}");
|
||||||
let expected = "(10)1";
|
let expected = "(10)1";
|
||||||
|
|
||||||
assertCorrectBinaryString(&data, expected);
|
assertCorrectBinaryString(&data, expected);
|
||||||
@@ -120,8 +108,7 @@ mod AnyAIDecoderTest {
|
|||||||
#[test]
|
#[test]
|
||||||
fn testAnyAIDecoderalphaFNC1() {
|
fn testAnyAIDecoderalphaFNC1() {
|
||||||
let data = format!(
|
let data = format!(
|
||||||
"{}{}{}{}{}",
|
"{HEADER}{NUMERIC10}{NUMERIC2ALPHA}{ALPHA_A}{ALPHA_FNC1}"
|
||||||
HEADER, NUMERIC10, NUMERIC2ALPHA, ALPHA_A, ALPHA_FNC1
|
|
||||||
);
|
);
|
||||||
let expected = "(10)A";
|
let expected = "(10)A";
|
||||||
|
|
||||||
@@ -131,8 +118,7 @@ mod AnyAIDecoderTest {
|
|||||||
#[test]
|
#[test]
|
||||||
fn testAnyAIDecoder646FNC1() {
|
fn testAnyAIDecoder646FNC1() {
|
||||||
let data = format!(
|
let data = format!(
|
||||||
"{}{}{}{}{}{}{}",
|
"{HEADER}{NUMERIC10}{NUMERIC2ALPHA}{ALPHA_A}{ISOIEC6462ALPHA}{I646_B}{I646_FNC1}"
|
||||||
HEADER, NUMERIC10, NUMERIC2ALPHA, ALPHA_A, ISOIEC6462ALPHA, I646_B, I646_FNC1
|
|
||||||
);
|
);
|
||||||
let expected = "(10)AB";
|
let expected = "(10)AB";
|
||||||
|
|
||||||
|
|||||||
@@ -215,13 +215,13 @@ fn processFixedAI(
|
|||||||
.take(fieldSize)
|
.take(fieldSize)
|
||||||
.collect(); //rawInformation.substring(aiSize, aiSize + fieldSize);
|
.collect(); //rawInformation.substring(aiSize, aiSize + fieldSize);
|
||||||
let remaining: String = rawInformation.chars().skip(aiSize + fieldSize).collect(); // rawInformation.substring(aiSize + fieldSize);
|
let remaining: String = rawInformation.chars().skip(aiSize + fieldSize).collect(); // rawInformation.substring(aiSize + fieldSize);
|
||||||
let result = format!("({}){}", ai, field);
|
let result = format!("({ai}){field}");
|
||||||
let parsedAI = parseFieldsInGeneralPurpose(&remaining)?;
|
let parsedAI = parseFieldsInGeneralPurpose(&remaining)?;
|
||||||
|
|
||||||
Ok(if parsedAI.is_empty() {
|
Ok(if parsedAI.is_empty() {
|
||||||
result
|
result
|
||||||
} else {
|
} else {
|
||||||
format!("{}{}", result, parsedAI)
|
format!("{result}{parsedAI}")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -237,13 +237,13 @@ fn processVariableAI(
|
|||||||
.min(aiSize + variableFieldSize);
|
.min(aiSize + variableFieldSize);
|
||||||
let field: String = rawInformation.chars().skip(aiSize).take(maxSize).collect(); // (aiSize, maxSize);
|
let field: String = rawInformation.chars().skip(aiSize).take(maxSize).collect(); // (aiSize, maxSize);
|
||||||
let remaining: String = rawInformation.chars().skip(maxSize).collect();
|
let remaining: String = rawInformation.chars().skip(maxSize).collect();
|
||||||
let result = format!("({}){}", ai, field); //'(' + ai + ')' + field;
|
let result = format!("({ai}){field}"); //'(' + ai + ')' + field;
|
||||||
let parsedAI = parseFieldsInGeneralPurpose(&remaining)?;
|
let parsedAI = parseFieldsInGeneralPurpose(&remaining)?;
|
||||||
|
|
||||||
Ok(if parsedAI.is_empty() {
|
Ok(if parsedAI.is_empty() {
|
||||||
result
|
result
|
||||||
} else {
|
} else {
|
||||||
format!("{}{}", result, parsedAI)
|
format!("{result}{parsedAI}")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -445,8 +445,7 @@ impl<'a> GeneralAppIdDecoder<'_> {
|
|||||||
62 => '/',
|
62 => '/',
|
||||||
_ => {
|
_ => {
|
||||||
return Err(Exceptions::IllegalStateException(Some(format!(
|
return Err(Exceptions::IllegalStateException(Some(format!(
|
||||||
"Decoding invalid alphanumeric value: {}",
|
"Decoding invalid alphanumeric value: {sixBitValue}"
|
||||||
sixBitValue
|
|
||||||
))))
|
))))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ impl Display for ExpandedRow {
|
|||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
write!(f, "{{ ")?;
|
write!(f, "{{ ")?;
|
||||||
for p in &self.pairs {
|
for p in &self.pairs {
|
||||||
write!(f, "{}", p)?;
|
write!(f, "{p}")?;
|
||||||
}
|
}
|
||||||
write!(f, " }}") //{:?} }} " , self.pairs )
|
write!(f, " }}") //{:?} }} " , self.pairs )
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ fn testDecodeRow2binary22() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn assertCorrectImage2binary(fileName: &str, expected: &str) {
|
fn assertCorrectImage2binary(fileName: &str, expected: &str) {
|
||||||
let path = format!("test_resources/blackbox/rssexpanded-1/{}", fileName);
|
let path = format!("test_resources/blackbox/rssexpanded-1/{fileName}");
|
||||||
|
|
||||||
let image = image::open(path).expect("file exists");
|
let image = image::open(path).expect("file exists");
|
||||||
let binaryMap = BinaryBitmap::new(Rc::new(GlobalHistogramBinarizer::new(Box::new(
|
let binaryMap = BinaryBitmap::new(Rc::new(GlobalHistogramBinarizer::new(Box::new(
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ fn testDecodeRow2result2() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn assertCorrectImage2result(fileName: &str, expected: ExpandedProductParsedRXingResult) {
|
fn assertCorrectImage2result(fileName: &str, expected: ExpandedProductParsedRXingResult) {
|
||||||
let path = format!("test_resources/blackbox/rssexpanded-1/{}", fileName);
|
let path = format!("test_resources/blackbox/rssexpanded-1/{fileName}");
|
||||||
|
|
||||||
let image = image::open(path).expect("image must exist");
|
let image = image::open(path).expect("image must exist");
|
||||||
let binaryMap = BinaryBitmap::new(Rc::new(GlobalHistogramBinarizer::new(Box::new(
|
let binaryMap = BinaryBitmap::new(Rc::new(GlobalHistogramBinarizer::new(Box::new(
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ fn testDecodeRow2string32() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn assertCorrectImage2string(fileName: &str, expected: &str) {
|
fn assertCorrectImage2string(fileName: &str, expected: &str) {
|
||||||
let path = format!("test_resources/blackbox/rssexpanded-1/{}", fileName);
|
let path = format!("test_resources/blackbox/rssexpanded-1/{fileName}");
|
||||||
|
|
||||||
let image = image::open(path).expect("load image");
|
let image = image::open(path).expect("load image");
|
||||||
let binaryMap = BinaryBitmap::new(Rc::new(GlobalHistogramBinarizer::new(Box::new(
|
let binaryMap = BinaryBitmap::new(Rc::new(GlobalHistogramBinarizer::new(Box::new(
|
||||||
|
|||||||
@@ -172,8 +172,7 @@ fn testDecodeDataCharacter() {
|
|||||||
|
|
||||||
fn readImage(fileName: &str) -> image::DynamicImage {
|
fn readImage(fileName: &str) -> image::DynamicImage {
|
||||||
image::open(format!(
|
image::open(format!(
|
||||||
"test_resources/blackbox/rssexpanded-1/{}",
|
"test_resources/blackbox/rssexpanded-1/{fileName}"
|
||||||
fileName
|
|
||||||
))
|
))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
// Path path = AbstractBlackBoxTestCase.buildTestBase("src/test/resources/blackbox/rssexpanded-1/").resolve(fileName);
|
// Path path = AbstractBlackBoxTestCase.buildTestBase("src/test/resources/blackbox/rssexpanded-1/").resolve(fileName);
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ use image::DynamicImage;
|
|||||||
use crate::{common::GlobalHistogramBinarizer, BinaryBitmap, BufferedImageLuminanceSource};
|
use crate::{common::GlobalHistogramBinarizer, BinaryBitmap, BufferedImageLuminanceSource};
|
||||||
|
|
||||||
fn getBufferedImage(fileName: &str) -> DynamicImage {
|
fn getBufferedImage(fileName: &str) -> DynamicImage {
|
||||||
let path = format!("test_resources/blackbox/rssexpandedstacked-2/{}", fileName);
|
let path = format!("test_resources/blackbox/rssexpandedstacked-2/{fileName}");
|
||||||
|
|
||||||
image::open(path).expect("load image")
|
image::open(path).expect("load image")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,13 +49,12 @@ impl Writer for UPCAWriter {
|
|||||||
) -> Result<crate::common::BitMatrix, crate::Exceptions> {
|
) -> Result<crate::common::BitMatrix, crate::Exceptions> {
|
||||||
if format != &BarcodeFormat::UPC_A {
|
if format != &BarcodeFormat::UPC_A {
|
||||||
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||||
"Can only encode UPC-A, but got {:?}",
|
"Can only encode UPC-A, but got {format:?}"
|
||||||
format
|
|
||||||
))));
|
))));
|
||||||
}
|
}
|
||||||
// Transform a UPC-A code into the equivalent EAN-13 code and write it that way
|
// Transform a UPC-A code into the equivalent EAN-13 code and write it that way
|
||||||
self.0.encode_with_hints(
|
self.0.encode_with_hints(
|
||||||
&format!("0{}", contents),
|
&format!("0{contents}"),
|
||||||
&BarcodeFormat::EAN_13,
|
&BarcodeFormat::EAN_13,
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
|
|||||||
@@ -69,8 +69,7 @@ impl OneDimensionalCodeWriter for UPCEWriter {
|
|||||||
// }},
|
// }},
|
||||||
_ => {
|
_ => {
|
||||||
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||||
"Requested contents should be 7 or 8 digits long, but got {}",
|
"Requested contents should be 7 or 8 digits long, but got {length}"
|
||||||
length
|
|
||||||
))))
|
))))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -209,11 +209,11 @@ impl UPCEANExtension5Support {
|
|||||||
let unitsString = (rawAmount / 100).to_string();
|
let unitsString = (rawAmount / 100).to_string();
|
||||||
let hundredths = rawAmount % 100;
|
let hundredths = rawAmount % 100;
|
||||||
let hundredthsString = if hundredths < 10 {
|
let hundredthsString = if hundredths < 10 {
|
||||||
format!("0{}", hundredths)
|
format!("0{hundredths}")
|
||||||
} else {
|
} else {
|
||||||
hundredths.to_string()
|
hundredths.to_string()
|
||||||
};
|
};
|
||||||
|
|
||||||
Some(format!("{}{}.{}", currency, unitsString, hundredthsString))
|
Some(format!("{currency}{unitsString}.{hundredthsString}"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -304,7 +304,7 @@ pub trait UPCEANReader: OneDReader {
|
|||||||
|
|
||||||
decodeRXingResult.putMetadata(
|
decodeRXingResult.putMetadata(
|
||||||
RXingResultMetadataType::SYMBOLOGY_IDENTIFIER,
|
RXingResultMetadataType::SYMBOLOGY_IDENTIFIER,
|
||||||
RXingResultMetadataValue::SymbologyIdentifier(format!("]E{}", symbologyIdentifier)),
|
RXingResultMetadataValue::SymbologyIdentifier(format!("]E{symbologyIdentifier}")),
|
||||||
);
|
);
|
||||||
|
|
||||||
Ok(decodeRXingResult)
|
Ok(decodeRXingResult)
|
||||||
|
|||||||
@@ -652,7 +652,7 @@ impl Display for DetectionRXingResult {
|
|||||||
// try (Formatter formatter = new Formatter()) {
|
// try (Formatter formatter = new Formatter()) {
|
||||||
for codewordsRow in 0..rowIndicatorColumn.as_ref().unwrap().getCodewords().len() {
|
for codewordsRow in 0..rowIndicatorColumn.as_ref().unwrap().getCodewords().len() {
|
||||||
// for (int codewordsRow = 0; codewordsRow < rowIndicatorColumn.getCodewords().length; codewordsRow++) {
|
// for (int codewordsRow = 0; codewordsRow < rowIndicatorColumn.getCodewords().length; codewordsRow++) {
|
||||||
write!(f, "CW {0:3}", codewordsRow)?;
|
write!(f, "CW {codewordsRow:3}")?;
|
||||||
// formatter.format("CW %3d:", codewordsRow);
|
// formatter.format("CW %3d:", codewordsRow);
|
||||||
for barcodeColumn in 0..self.barcodeColumnCount + 2 {
|
for barcodeColumn in 0..self.barcodeColumnCount + 2 {
|
||||||
// for (int barcodeColumn = 0; barcodeColumn < barcodeColumnCount + 2; barcodeColumn++) {
|
// for (int barcodeColumn = 0; barcodeColumn < barcodeColumnCount + 2; barcodeColumn++) {
|
||||||
|
|||||||
@@ -133,7 +133,7 @@ impl Display for DetectionRXingResultColumn {
|
|||||||
for codeword in &self.codewords {
|
for codeword in &self.codewords {
|
||||||
// for (Codeword codeword : codewords) {
|
// for (Codeword codeword : codewords) {
|
||||||
if codeword.is_none() {
|
if codeword.is_none() {
|
||||||
writeln!(f, "{:3}: | ", row)?;
|
writeln!(f, "{row:3}: | ")?;
|
||||||
row += 1;
|
row += 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,8 +41,7 @@ impl TryFrom<&String> for Compaction {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(Exceptions::FormatException(Some(format!(
|
Err(Exceptions::FormatException(Some(format!(
|
||||||
"Compaction must be 0-3 (inclusivie). Found: {}",
|
"Compaction must be 0-3 (inclusivie). Found: {value}"
|
||||||
value
|
|
||||||
))))
|
))))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -247,7 +247,7 @@ impl PDF417 {
|
|||||||
//4. step: low-level encoding
|
//4. step: low-level encoding
|
||||||
let mut barcode_matrix = BarcodeMatrix::new(rows as usize, cols as usize);
|
let mut barcode_matrix = BarcodeMatrix::new(rows as usize, cols as usize);
|
||||||
self.encodeLowLevel(
|
self.encodeLowLevel(
|
||||||
&format!("{}{}", dataCodewords, ec),
|
&format!("{dataCodewords}{ec}"),
|
||||||
cols,
|
cols,
|
||||||
rows,
|
rows,
|
||||||
errorCorrectionLevel,
|
errorCorrectionLevel,
|
||||||
|
|||||||
@@ -806,8 +806,7 @@ fn encodingECI(eci: i32, sb: &mut String) -> Result<(), Exceptions> {
|
|||||||
sb.push(char::from_u32((810900 - eci) as u32).unwrap());
|
sb.push(char::from_u32((810900 - eci) as u32).unwrap());
|
||||||
} else {
|
} else {
|
||||||
return Err(Exceptions::WriterException(Some(format!(
|
return Err(Exceptions::WriterException(Some(format!(
|
||||||
"ECI number not in valid range from 0..811799, but was {}",
|
"ECI number not in valid range from 0..811799, but was {eci}"
|
||||||
eci
|
|
||||||
))));
|
))));
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -60,8 +60,7 @@ impl Writer for PDF417Writer {
|
|||||||
) -> Result<crate::common::BitMatrix, crate::Exceptions> {
|
) -> Result<crate::common::BitMatrix, crate::Exceptions> {
|
||||||
if format != &BarcodeFormat::PDF_417 {
|
if format != &BarcodeFormat::PDF_417 {
|
||||||
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||||
"Can only encode PDF_417, but got {}",
|
"Can only encode PDF_417, but got {format}"
|
||||||
format
|
|
||||||
))));
|
))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -252,7 +252,7 @@ impl LuminanceSource for PlanarYUVLuminanceSource {
|
|||||||
fn getRow(&self, y: usize) -> Vec<u8> {
|
fn getRow(&self, y: usize) -> Vec<u8> {
|
||||||
if y >= self.getHeight() {
|
if y >= self.getHeight() {
|
||||||
//throw new IllegalArgumentException("Requested row is outside the image: " + y);
|
//throw new IllegalArgumentException("Requested row is outside the image: " + y);
|
||||||
panic!("Requested row is outside the image: {}", y);
|
panic!("Requested row is outside the image: {y}");
|
||||||
}
|
}
|
||||||
let width = self.getWidth();
|
let width = self.getWidth();
|
||||||
|
|
||||||
|
|||||||
@@ -37,8 +37,7 @@ impl BitMatrixParser {
|
|||||||
let dimension = bit_matrix.getHeight();
|
let dimension = bit_matrix.getHeight();
|
||||||
if dimension < 21 || (dimension & 0x03) != 1 {
|
if dimension < 21 || (dimension & 0x03) != 1 {
|
||||||
Err(Exceptions::FormatException(Some(format!(
|
Err(Exceptions::FormatException(Some(format!(
|
||||||
"{} < 21 || ({} % 0x03) != 1",
|
"{dimension} < 21 || ({dimension} % 0x03) != 1"
|
||||||
dimension, dimension
|
|
||||||
))))
|
))))
|
||||||
} else {
|
} else {
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
|
|||||||
@@ -231,8 +231,7 @@ impl TryFrom<u8> for DataMask {
|
|||||||
6 => Ok(DataMask::DATA_MASK_110),
|
6 => Ok(DataMask::DATA_MASK_110),
|
||||||
7 => Ok(DataMask::DATA_MASK_111),
|
7 => Ok(DataMask::DATA_MASK_111),
|
||||||
_ => Err(Exceptions::IllegalArgumentException(Some(format!(
|
_ => Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||||
"{} is not between 0 and 7",
|
"{value} is not between 0 and 7"
|
||||||
value
|
|
||||||
)))),
|
)))),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ fn testMask(mask: DataMask, dimension: u32, condition: MaskCondition) {
|
|||||||
// for (int i = 0; i < dimension; i++) {
|
// for (int i = 0; i < dimension; i++) {
|
||||||
for j in 0..dimension {
|
for j in 0..dimension {
|
||||||
// for (int j = 0; j < dimension; j++) {
|
// for (int j = 0; j < dimension; j++) {
|
||||||
assert_eq!(condition(i, j), bits.get(j, i), "({},{})", i, j);
|
assert_eq!(condition(i, j), bits.get(j, i), "({i},{j})");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,8 +96,7 @@ pub fn decode(
|
|||||||
currentCharacterSetECI = Some(CharacterSetECI::getCharacterSetECIByValue(value)?);
|
currentCharacterSetECI = Some(CharacterSetECI::getCharacterSetECIByValue(value)?);
|
||||||
if currentCharacterSetECI.is_none() {
|
if currentCharacterSetECI.is_none() {
|
||||||
return Err(Exceptions::FormatException(Some(format!(
|
return Err(Exceptions::FormatException(Some(format!(
|
||||||
"Value of {} not valid",
|
"Value of {value} not valid"
|
||||||
value
|
|
||||||
))));
|
))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,8 +48,7 @@ impl ErrorCorrectionLevel {
|
|||||||
2 => Ok(Self::H),
|
2 => Ok(Self::H),
|
||||||
3 => Ok(Self::Q),
|
3 => Ok(Self::Q),
|
||||||
_ => Err(Exceptions::IllegalArgumentException(Some(format!(
|
_ => Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||||
"{} is not a valid bit selection",
|
"{bits} is not a valid bit selection"
|
||||||
bits
|
|
||||||
)))),
|
)))),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -111,8 +110,7 @@ impl FromStr for ErrorCorrectionLevel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||||
"could not parse {} into an ec level",
|
"could not parse {s} into an ec level"
|
||||||
s
|
|
||||||
))));
|
))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,8 +69,7 @@ impl Mode {
|
|||||||
Ok(Self::HANZI)
|
Ok(Self::HANZI)
|
||||||
}
|
}
|
||||||
_ => Err(Exceptions::IllegalArgumentException(Some(format!(
|
_ => Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||||
"{} is not valid",
|
"{bits} is not valid"
|
||||||
bits
|
|
||||||
)))),
|
)))),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ impl fmt::Display for ByteMatrix {
|
|||||||
}
|
}
|
||||||
result.push('\n');
|
result.push('\n');
|
||||||
}
|
}
|
||||||
write!(f, "{}", result)
|
write!(f, "{result}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -186,8 +186,7 @@ pub fn getDataMaskBit(maskPattern: u32, x: u32, y: u32) -> Result<bool, Exceptio
|
|||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||||
"Invalid mask pattern: {}",
|
"Invalid mask pattern: {maskPattern}"
|
||||||
maskPattern
|
|
||||||
))))
|
))))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -161,8 +161,7 @@ impl MinimalEncoder {
|
|||||||
&self.ecLevel,
|
&self.ecLevel,
|
||||||
) {
|
) {
|
||||||
return Err(Exceptions::WriterException(Some(format!(
|
return Err(Exceptions::WriterException(Some(format!(
|
||||||
"Data too big for version {}",
|
"Data too big for version {version}"
|
||||||
version
|
|
||||||
))));
|
))));
|
||||||
}
|
}
|
||||||
Ok(result)
|
Ok(result)
|
||||||
@@ -270,8 +269,7 @@ impl MinimalEncoder {
|
|||||||
Mode::BYTE => Ok(3),
|
Mode::BYTE => Ok(3),
|
||||||
Mode::KANJI => Ok(0),
|
Mode::KANJI => Ok(0),
|
||||||
_ => Err(Exceptions::IllegalArgumentException(Some(format!(
|
_ => Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||||
"Illegal mode {:?}",
|
"Illegal mode {mode:?}"
|
||||||
mode
|
|
||||||
)))),
|
)))),
|
||||||
}
|
}
|
||||||
// switch (mode) {
|
// switch (mode) {
|
||||||
@@ -956,7 +954,7 @@ impl fmt::Display for RXingResultList {
|
|||||||
result.push_str(¤t.to_string());
|
result.push_str(¤t.to_string());
|
||||||
previous = Some(current);
|
previous = Some(current);
|
||||||
}
|
}
|
||||||
write!(f, "{}", result)
|
write!(f, "{result}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1141,6 +1139,6 @@ impl fmt::Display for RXingResultNode {
|
|||||||
}
|
}
|
||||||
result.push(')');
|
result.push(')');
|
||||||
|
|
||||||
write!(f, "{}", result)
|
write!(f, "{result}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ impl fmt::Display for QRCode {
|
|||||||
}
|
}
|
||||||
result.push_str(">>\n");
|
result.push_str(">>\n");
|
||||||
|
|
||||||
write!(f, "{}", result)
|
write!(f, "{result}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -430,8 +430,7 @@ pub fn terminateBits(num_data_bytes: u32, bits: &mut BitArray) -> Result<(), Exc
|
|||||||
let capacity = num_data_bytes * 8;
|
let capacity = num_data_bytes * 8;
|
||||||
if bits.getSize() > capacity as usize {
|
if bits.getSize() > capacity as usize {
|
||||||
return Err(Exceptions::WriterException(Some(format!(
|
return Err(Exceptions::WriterException(Some(format!(
|
||||||
"data bits cannot fit in the QR Code{} > ",
|
"data bits cannot fit in the QR Code{capacity} > "
|
||||||
capacity
|
|
||||||
))));
|
))));
|
||||||
// throw new WriterException("data bits cannot fit in the QR Code" + bits.getSize() + " > " +
|
// throw new WriterException("data bits cannot fit in the QR Code" + bits.getSize() + " > " +
|
||||||
// capacity);
|
// capacity);
|
||||||
@@ -701,8 +700,7 @@ pub fn appendBytes(
|
|||||||
Mode::BYTE => append8BitBytes(content, bits, encoding),
|
Mode::BYTE => append8BitBytes(content, bits, encoding),
|
||||||
Mode::KANJI => appendKanjiBytes(content, bits),
|
Mode::KANJI => appendKanjiBytes(content, bits),
|
||||||
_ => Err(Exceptions::WriterException(Some(format!(
|
_ => Err(Exceptions::WriterException(Some(format!(
|
||||||
"Invalid mode: {:?}",
|
"Invalid mode: {mode:?}"
|
||||||
mode
|
|
||||||
)))),
|
)))),
|
||||||
}
|
}
|
||||||
// switch (mode) {
|
// switch (mode) {
|
||||||
|
|||||||
@@ -66,16 +66,14 @@ impl Writer for QRCodeWriter {
|
|||||||
|
|
||||||
if format != &BarcodeFormat::QR_CODE {
|
if format != &BarcodeFormat::QR_CODE {
|
||||||
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||||
"Can only encode QR_CODE, but got {:?}",
|
"Can only encode QR_CODE, but got {format:?}"
|
||||||
format
|
|
||||||
))));
|
))));
|
||||||
// throw new IllegalArgumentException("Can only encode QR_CODE, but got " + format);
|
// throw new IllegalArgumentException("Can only encode QR_CODE, but got " + format);
|
||||||
}
|
}
|
||||||
|
|
||||||
if width < 0 || height < 0 {
|
if width < 0 || height < 0 {
|
||||||
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||||
"Requested dimensions are too small: {}x{}",
|
"Requested dimensions are too small: {width}x{height}"
|
||||||
width, height
|
|
||||||
))));
|
))));
|
||||||
// throw new IllegalArgumentException("Requested dimensions are too small: " + width + 'x' +
|
// throw new IllegalArgumentException("Requested dimensions are too small: " + width + 'x' +
|
||||||
// height);
|
// height);
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ pub struct RGBLuminanceSource {
|
|||||||
impl LuminanceSource for RGBLuminanceSource {
|
impl LuminanceSource for RGBLuminanceSource {
|
||||||
fn getRow(&self, y: usize) -> Vec<u8> {
|
fn getRow(&self, y: usize) -> Vec<u8> {
|
||||||
if y >= self.getHeight() {
|
if y >= self.getHeight() {
|
||||||
panic!("Requested row is outside the image: {}", y);
|
panic!("Requested row is outside the image: {y}");
|
||||||
}
|
}
|
||||||
let width = self.getWidth();
|
let width = self.getWidth();
|
||||||
|
|
||||||
|
|||||||
@@ -263,7 +263,7 @@ impl<T: Reader> AbstractBlackBoxTestCase<T> {
|
|||||||
misread_counts[x] += 1;
|
misread_counts[x] += 1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log::fine(format!("could not read at rotation {}", rotation));
|
log::fine(format!("could not read at rotation {rotation}"));
|
||||||
}
|
}
|
||||||
// try {
|
// try {
|
||||||
// if (decode(bitmap, rotation, expectedText, expectedMetadata, false)) {
|
// if (decode(bitmap, rotation, expectedText, expectedMetadata, false)) {
|
||||||
@@ -287,7 +287,7 @@ impl<T: Reader> AbstractBlackBoxTestCase<T> {
|
|||||||
try_harder_misread_counts[x] += 1;
|
try_harder_misread_counts[x] += 1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log::fine(format!("could not read at rotation {} w/TH", rotation));
|
log::fine(format!("could not read at rotation {rotation} w/TH"));
|
||||||
}
|
}
|
||||||
// try {
|
// try {
|
||||||
// if (decode(bitmap, rotation, expectedText, expectedMetadata, true)) {
|
// if (decode(bitmap, rotation, expectedText, expectedMetadata, true)) {
|
||||||
@@ -393,8 +393,7 @@ impl<T: Reader> AbstractBlackBoxTestCase<T> {
|
|||||||
);
|
);
|
||||||
assert!(
|
assert!(
|
||||||
try_harder_counts[x] >= test_rxing_result.get_try_harder_count() as usize,
|
try_harder_counts[x] >= test_rxing_result.get_try_harder_count() as usize,
|
||||||
"Try harder, {}",
|
"Try harder, {label}",
|
||||||
label,
|
|
||||||
);
|
);
|
||||||
let label = format!(
|
let label = format!(
|
||||||
"Rotation {} degrees: Too many images misread",
|
"Rotation {} degrees: Too many images misread",
|
||||||
@@ -408,8 +407,7 @@ impl<T: Reader> AbstractBlackBoxTestCase<T> {
|
|||||||
assert!(
|
assert!(
|
||||||
try_harder_misread_counts[x]
|
try_harder_misread_counts[x]
|
||||||
<= test_rxing_result.get_max_try_harder_misreads() as usize,
|
<= test_rxing_result.get_max_try_harder_misreads() as usize,
|
||||||
"Try harder, {}",
|
"Try harder, {label}"
|
||||||
label
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -468,8 +466,7 @@ impl<T: Reader> AbstractBlackBoxTestCase<T> {
|
|||||||
let result_text = result.getText();
|
let result_text = result.getText();
|
||||||
if expected_text != result_text {
|
if expected_text != result_text {
|
||||||
log::info(format!(
|
log::info(format!(
|
||||||
"Content mismatch: expected '{}' but got '{}'{}",
|
"Content mismatch: expected '{expected_text}' but got '{result_text}'{suffix}"
|
||||||
expected_text, result_text, suffix
|
|
||||||
));
|
));
|
||||||
return Ok(false);
|
return Ok(false);
|
||||||
}
|
}
|
||||||
@@ -481,8 +478,7 @@ impl<T: Reader> AbstractBlackBoxTestCase<T> {
|
|||||||
let actual_value = result_metadata.get(key);
|
let actual_value = result_metadata.get(key);
|
||||||
if actual_value.is_none() || !(value == actual_value.unwrap()) {
|
if actual_value.is_none() || !(value == actual_value.unwrap()) {
|
||||||
log::info(format!(
|
log::info(format!(
|
||||||
"Metadata mismatch for key '{:?}': expected '{:?}' but got '{:?}'",
|
"Metadata mismatch for key '{key:?}': expected '{value:?}' but got '{actual_value:?}'"
|
||||||
key, value, actual_value
|
|
||||||
));
|
));
|
||||||
return Ok(false);
|
return Ok(false);
|
||||||
}
|
}
|
||||||
@@ -607,6 +603,6 @@ mod log {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn prn(level: &str, data: String) {
|
fn prn(level: &str, data: String) {
|
||||||
println!("{} :: {}", level, data)
|
println!("{level} :: {data}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ impl<T: MultipleBarcodeReader + Reader> PDF417MultiImageSpanAbstractBlackBoxTest
|
|||||||
|
|
||||||
for (name, files) in &image_files {
|
for (name, files) in &image_files {
|
||||||
// for (Entry<String,List<Path>> testImageGroup : imageFiles.entrySet()) {
|
// for (Entry<String,List<Path>> testImageGroup : imageFiles.entrySet()) {
|
||||||
log::fine(format!("Starting Image Group {}", name));
|
log::fine(format!("Starting Image Group {name}"));
|
||||||
|
|
||||||
let file_base_name = name; //testImageGroup.getKey();
|
let file_base_name = name; //testImageGroup.getKey();
|
||||||
// let expectedText : String;
|
// let expectedText : String;
|
||||||
@@ -408,7 +408,7 @@ impl<T: MultipleBarcodeReader + Reader> PDF417MultiImageSpanAbstractBlackBoxTest
|
|||||||
misread_counts[x] += 1;
|
misread_counts[x] += 1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log::fine(format!("could not read at rotation {}", rotation));
|
log::fine(format!("could not read at rotation {rotation}"));
|
||||||
}
|
}
|
||||||
// try {
|
// try {
|
||||||
// if (decode(bitmap, rotation, expectedText, expectedMetadata, false)) {
|
// if (decode(bitmap, rotation, expectedText, expectedMetadata, false)) {
|
||||||
@@ -432,7 +432,7 @@ impl<T: MultipleBarcodeReader + Reader> PDF417MultiImageSpanAbstractBlackBoxTest
|
|||||||
try_harder_misread_counts[x] += 1;
|
try_harder_misread_counts[x] += 1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log::fine(format!("could not read at rotation {} w/TH", rotation));
|
log::fine(format!("could not read at rotation {rotation} w/TH"));
|
||||||
}
|
}
|
||||||
// try {
|
// try {
|
||||||
// if (decode(bitmap, rotation, expectedText, expectedMetadata, true)) {
|
// if (decode(bitmap, rotation, expectedText, expectedMetadata, true)) {
|
||||||
@@ -538,8 +538,7 @@ impl<T: MultipleBarcodeReader + Reader> PDF417MultiImageSpanAbstractBlackBoxTest
|
|||||||
);
|
);
|
||||||
assert!(
|
assert!(
|
||||||
try_harder_counts[x] >= test_rxing_result.get_try_harder_count() as usize,
|
try_harder_counts[x] >= test_rxing_result.get_try_harder_count() as usize,
|
||||||
"Try harder, {}",
|
"Try harder, {label}",
|
||||||
label,
|
|
||||||
);
|
);
|
||||||
let label = format!(
|
let label = format!(
|
||||||
"Rotation {} degrees: Too many images misread",
|
"Rotation {} degrees: Too many images misread",
|
||||||
@@ -553,8 +552,7 @@ impl<T: MultipleBarcodeReader + Reader> PDF417MultiImageSpanAbstractBlackBoxTest
|
|||||||
assert!(
|
assert!(
|
||||||
try_harder_misread_counts[x]
|
try_harder_misread_counts[x]
|
||||||
<= test_rxing_result.get_max_try_harder_misreads() as usize,
|
<= test_rxing_result.get_max_try_harder_misreads() as usize,
|
||||||
"Try harder, {}",
|
"Try harder, {label}"
|
||||||
label
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -613,8 +611,7 @@ impl<T: MultipleBarcodeReader + Reader> PDF417MultiImageSpanAbstractBlackBoxTest
|
|||||||
let result_text = result.getText();
|
let result_text = result.getText();
|
||||||
if expected_text != result_text {
|
if expected_text != result_text {
|
||||||
log::info(format!(
|
log::info(format!(
|
||||||
"Content mismatch: expected '{}' but got '{}'{}",
|
"Content mismatch: expected '{expected_text}' but got '{result_text}'{suffix}"
|
||||||
expected_text, result_text, suffix
|
|
||||||
));
|
));
|
||||||
return Ok(false);
|
return Ok(false);
|
||||||
}
|
}
|
||||||
@@ -626,8 +623,7 @@ impl<T: MultipleBarcodeReader + Reader> PDF417MultiImageSpanAbstractBlackBoxTest
|
|||||||
let actual_value = result_metadata.get(key);
|
let actual_value = result_metadata.get(key);
|
||||||
if actual_value.is_none() || !(value == actual_value.unwrap()) {
|
if actual_value.is_none() || !(value == actual_value.unwrap()) {
|
||||||
log::info(format!(
|
log::info(format!(
|
||||||
"Metadata mismatch for key '{:?}': expected '{:?}' but got '{:?}'",
|
"Metadata mismatch for key '{key:?}': expected '{value:?}' but got '{actual_value:?}'"
|
||||||
key, value, actual_value
|
|
||||||
));
|
));
|
||||||
return Ok(false);
|
return Ok(false);
|
||||||
}
|
}
|
||||||
@@ -804,6 +800,6 @@ mod log {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn prn(level: &str, data: String) {
|
fn prn(level: &str, data: String) {
|
||||||
println!("{} :: {}", level, data)
|
println!("{level} :: {data}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user