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:
@@ -37,7 +37,7 @@ impl OneDimensionalCodeWriter for CodaBarWriter {
|
||||
fn encode_oned(&self, contents: &str) -> Result<Vec<bool>, crate::Exceptions> {
|
||||
let contents = if contents.chars().count() < 2 {
|
||||
// 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 {
|
||||
// Verify input and calculate decoded length.
|
||||
let firstChar = contents.chars().next().unwrap().to_ascii_uppercase();
|
||||
@@ -53,8 +53,7 @@ impl OneDimensionalCodeWriter for CodaBarWriter {
|
||||
if startsNormal {
|
||||
if !endsNormal {
|
||||
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||
"Invalid start/end guards: {}",
|
||||
contents
|
||||
"Invalid start/end guards: {contents}"
|
||||
))));
|
||||
}
|
||||
// else already has valid start/end
|
||||
@@ -62,8 +61,7 @@ impl OneDimensionalCodeWriter for CodaBarWriter {
|
||||
} else if startsAlt {
|
||||
if !endsAlt {
|
||||
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||
"Invalid start/end guards: {}",
|
||||
contents
|
||||
"Invalid start/end guards: {contents}"
|
||||
))));
|
||||
}
|
||||
// else already has valid start/end
|
||||
@@ -72,12 +70,11 @@ impl OneDimensionalCodeWriter for CodaBarWriter {
|
||||
// Doesn't start with a guard
|
||||
if endsNormal || endsAlt {
|
||||
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||
"Invalid start/end guards: {}",
|
||||
contents
|
||||
"Invalid start/end guards: {contents}"
|
||||
))));
|
||||
}
|
||||
// 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;
|
||||
} else {
|
||||
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||
"Cannot encode : '{}'",
|
||||
ch
|
||||
"Cannot encode : '{ch}'"
|
||||
))));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -356,7 +356,7 @@ impl OneDReader for Code128Reader {
|
||||
|
||||
resultObject.putMetadata(
|
||||
RXingResultMetadataType::SYMBOLOGY_IDENTIFIER,
|
||||
RXingResultMetadataValue::SymbologyIdentifier(format!("]C{}", symbologyModifier)),
|
||||
RXingResultMetadataValue::SymbologyIdentifier(format!("]C{symbologyModifier}")),
|
||||
);
|
||||
|
||||
Ok(resultObject)
|
||||
|
||||
@@ -96,8 +96,7 @@ fn check(contents: &str, hints: &crate::EncodingHintDictionary) -> Result<i32, E
|
||||
// Check length
|
||||
if !(1..=80).contains(&length) {
|
||||
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||
"Contents length should be between 1 and 80 characters, but got {}",
|
||||
length
|
||||
"Contents length should be between 1 and 80 characters, but got {length}"
|
||||
))));
|
||||
}
|
||||
|
||||
@@ -111,8 +110,7 @@ fn check(contents: &str, hints: &crate::EncodingHintDictionary) -> Result<i32, E
|
||||
"C" => forcedCodeSet = CODE_CODE_C as i32,
|
||||
_ => {
|
||||
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||
"Unsupported code set hint: {}",
|
||||
codeSetHint
|
||||
"Unsupported code set hint: {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
|
||||
// shift and manual code change are not supported
|
||||
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||
"Bad character in input: ASCII value={}",
|
||||
c
|
||||
"Bad character in input: ASCII value={c}"
|
||||
))));
|
||||
}
|
||||
}
|
||||
@@ -149,8 +146,7 @@ fn check(contents: &str, hints: &crate::EncodingHintDictionary) -> Result<i32, E
|
||||
{
|
||||
if c > 95 && c <= 127 {
|
||||
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||
"Bad character in input for forced code set A: ASCII value={}",
|
||||
c
|
||||
"Bad character in input for forced code set A: ASCII value={c}"
|
||||
))));
|
||||
}
|
||||
}
|
||||
@@ -159,8 +155,7 @@ fn check(contents: &str, hints: &crate::EncodingHintDictionary) -> Result<i32, E
|
||||
{
|
||||
if c <= 32 {
|
||||
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||
"Bad character in input for forced code set B: ASCII value={}",
|
||||
c
|
||||
"Bad character in input for forced code set B: ASCII value={c}"
|
||||
))));
|
||||
}
|
||||
}
|
||||
@@ -174,8 +169,7 @@ fn check(contents: &str, hints: &crate::EncodingHintDictionary) -> Result<i32, E
|
||||
|| ch == ESCAPE_FNC_4
|
||||
{
|
||||
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||
"Bad character in input for forced code set C: ASCII value={}",
|
||||
c
|
||||
"Bad character in input for forced code set C: ASCII value={c}"
|
||||
))));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -311,7 +311,7 @@ fn testEncodeSwitchBetweenCodesetsAAndB() {
|
||||
fn testEncode(toEncode: &str, expected: &str) {
|
||||
let result = encode(toEncode, false, toEncode).expect("encode");
|
||||
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 result = encode(toEncode, true, toEncode).expect("encode");
|
||||
|
||||
@@ -34,8 +34,7 @@ impl OneDimensionalCodeWriter for Code39Writer {
|
||||
let mut length = contents.chars().count();
|
||||
if length > 80 {
|
||||
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||
"Requested contents should be less than 80 digits long, but got {}",
|
||||
length
|
||||
"Requested contents should be less than 80 digits long, but got {length}"
|
||||
))));
|
||||
}
|
||||
|
||||
@@ -50,7 +49,7 @@ impl OneDimensionalCodeWriter for Code39Writer {
|
||||
contents = Self::tryToConvertToExtendedMode(&contents)?;
|
||||
length = contents.chars().count();
|
||||
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;
|
||||
}
|
||||
@@ -156,8 +155,7 @@ impl Code39Writer {
|
||||
.push(char::from_u32('P' as u32 + (character as u32 - 123)).unwrap());
|
||||
} else {
|
||||
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||
"Requested content contains a non-encodable character: '{}'",
|
||||
character
|
||||
"Requested content contains a non-encodable character: '{character}'"
|
||||
))));
|
||||
}
|
||||
}
|
||||
@@ -249,8 +247,7 @@ mod Code39WriterTestCase {
|
||||
assert_eq!(
|
||||
expected,
|
||||
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 length = contents.chars().count();
|
||||
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
|
||||
@@ -197,8 +197,7 @@ impl Code93Writer {
|
||||
.push(char::from_u32('P' as u32 + character as u32 - '{' as u32).unwrap());
|
||||
} else {
|
||||
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||
"Requested content contains a non-encodable character: '{}'",
|
||||
character
|
||||
"Requested content contains a non-encodable character: '{character}'"
|
||||
))));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,8 +61,7 @@ impl OneDimensionalCodeWriter for EAN13Writer {
|
||||
}
|
||||
_ => {
|
||||
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||
"Requested contents should be 12 or 13 digits long, but got {}",
|
||||
length
|
||||
"Requested contents should be 12 or 13 digits long, but got {length}"
|
||||
))))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,8 +71,7 @@ impl OneDimensionalCodeWriter for EAN8Writer {
|
||||
// }},
|
||||
_ => {
|
||||
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||
"Requested contents should be 7 or 8 digits long, but got {}",
|
||||
length
|
||||
"Requested contents should be 7 or 8 digits long, but got {length}"
|
||||
))))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,8 +38,7 @@ impl OneDimensionalCodeWriter for ITFWriter {
|
||||
}
|
||||
if length > 80 {
|
||||
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||
"Requested contents should be less than 80 digits long, but got {}",
|
||||
length
|
||||
"Requested contents should be less than 80 digits long, but got {length}"
|
||||
))));
|
||||
}
|
||||
|
||||
|
||||
@@ -173,15 +173,13 @@ impl Writer for L {
|
||||
|
||||
if width < 0 || height < 0 {
|
||||
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||
"Negative size is not allowed. Input: {}x{}",
|
||||
width, height
|
||||
"Negative size is not allowed. Input: {width}x{height}"
|
||||
))));
|
||||
}
|
||||
if let Some(supportedFormats) = self.getSupportedWriteFormats() {
|
||||
if !supportedFormats.contains(format) {
|
||||
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||
"Can only encode {:?}, but got {:?}",
|
||||
supportedFormats, format
|
||||
"Can only encode {supportedFormats:?}, but got {format:?}"
|
||||
))));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,7 +150,6 @@ pub fn createDecoder<'a>(
|
||||
}
|
||||
|
||||
Err(Exceptions::IllegalStateException(Some(format!(
|
||||
"unknown decoder: {}",
|
||||
information
|
||||
"unknown decoder: {information}"
|
||||
))))
|
||||
}
|
||||
|
||||
@@ -83,8 +83,7 @@ mod AI013103DecoderTest {
|
||||
#[test]
|
||||
fn test0131031() {
|
||||
let data = format!(
|
||||
"{}{}{}",
|
||||
HEADER, COMPRESSED_GTIN900123456798908, COMPRESSED15BIT_WEIGHT1750
|
||||
"{HEADER}{COMPRESSED_GTIN900123456798908}{COMPRESSED15BIT_WEIGHT1750}"
|
||||
);
|
||||
let expected = "(01)90012345678908(3103)001750";
|
||||
assertCorrectBinaryString(&data, expected);
|
||||
@@ -93,8 +92,7 @@ mod AI013103DecoderTest {
|
||||
#[test]
|
||||
fn test0131032() {
|
||||
let data = format!(
|
||||
"{}{}{}",
|
||||
HEADER, COMPRESSED_GTIN900000000000008, COMPRESSED15BIT_WEIGHT0
|
||||
"{HEADER}{COMPRESSED_GTIN900000000000008}{COMPRESSED15BIT_WEIGHT0}"
|
||||
);
|
||||
let expected = "(01)90000000000003(3103)000000";
|
||||
assertCorrectBinaryString(&data, expected);
|
||||
@@ -104,8 +102,7 @@ mod AI013103DecoderTest {
|
||||
#[should_panic]
|
||||
fn test013103invalid() {
|
||||
let data = format!(
|
||||
"{}{}{}..",
|
||||
HEADER, COMPRESSED_GTIN900123456798908, COMPRESSED15BIT_WEIGHT1750
|
||||
"{HEADER}{COMPRESSED_GTIN900123456798908}{COMPRESSED15BIT_WEIGHT1750}.."
|
||||
);
|
||||
assertCorrectBinaryString(&data, "");
|
||||
}
|
||||
|
||||
@@ -35,8 +35,7 @@ const HEADER: &str = "..X.X";
|
||||
#[test]
|
||||
fn test0132021() {
|
||||
let data = format!(
|
||||
"{}{}{}",
|
||||
HEADER, COMPRESSED_GTIN900123456798908, COMPRESSED15BIT_WEIGHT1750
|
||||
"{HEADER}{COMPRESSED_GTIN900123456798908}{COMPRESSED15BIT_WEIGHT1750}"
|
||||
);
|
||||
let expected = "(01)90012345678908(3202)001750";
|
||||
|
||||
@@ -46,8 +45,7 @@ fn test0132021() {
|
||||
#[test]
|
||||
fn test0132031() {
|
||||
let data = format!(
|
||||
"{}{}{}",
|
||||
HEADER, COMPRESSED_GTIN900123456798908, COMPRESSED15BIT_WEIGHT11750
|
||||
"{HEADER}{COMPRESSED_GTIN900123456798908}{COMPRESSED15BIT_WEIGHT11750}"
|
||||
);
|
||||
let expected = "(01)90012345678908(3203)001750";
|
||||
|
||||
|
||||
@@ -151,11 +151,7 @@ mod AI013X0X1XDecoderTest {
|
||||
#[test]
|
||||
fn test01310X1XendDate() {
|
||||
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";
|
||||
|
||||
@@ -165,11 +161,7 @@ mod AI013X0X1XDecoderTest {
|
||||
#[test]
|
||||
fn test01310X111() {
|
||||
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";
|
||||
|
||||
@@ -179,11 +171,7 @@ mod AI013X0X1XDecoderTest {
|
||||
#[test]
|
||||
fn test01320X111() {
|
||||
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";
|
||||
|
||||
@@ -193,11 +181,7 @@ mod AI013X0X1XDecoderTest {
|
||||
#[test]
|
||||
fn test01310X131() {
|
||||
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";
|
||||
|
||||
@@ -207,11 +191,7 @@ mod AI013X0X1XDecoderTest {
|
||||
#[test]
|
||||
fn test01320X131() {
|
||||
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";
|
||||
|
||||
@@ -221,11 +201,7 @@ mod AI013X0X1XDecoderTest {
|
||||
#[test]
|
||||
fn test01310X151() {
|
||||
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";
|
||||
|
||||
@@ -235,11 +211,7 @@ mod AI013X0X1XDecoderTest {
|
||||
#[test]
|
||||
fn test01320X151() {
|
||||
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";
|
||||
|
||||
@@ -249,11 +221,7 @@ mod AI013X0X1XDecoderTest {
|
||||
#[test]
|
||||
fn test01310X171() {
|
||||
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";
|
||||
|
||||
@@ -263,11 +231,7 @@ mod AI013X0X1XDecoderTest {
|
||||
#[test]
|
||||
fn test01320X171() {
|
||||
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";
|
||||
|
||||
|
||||
@@ -70,8 +70,7 @@ mod AnyAIDecoderTest {
|
||||
#[test]
|
||||
fn testAnyAIDecoder1() {
|
||||
let data = format!(
|
||||
"{}{}{}{}{}{}{}",
|
||||
HEADER, NUMERIC10, NUMERIC12, NUMERIC2ALPHA, ALPHA_A, ALPHA2NUMERIC, NUMERIC12
|
||||
"{HEADER}{NUMERIC10}{NUMERIC12}{NUMERIC2ALPHA}{ALPHA_A}{ALPHA2NUMERIC}{NUMERIC12}"
|
||||
);
|
||||
let expected = "(10)12A12";
|
||||
|
||||
@@ -81,8 +80,7 @@ mod AnyAIDecoderTest {
|
||||
#[test]
|
||||
fn testAnyAIDecoder2() {
|
||||
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";
|
||||
|
||||
@@ -92,17 +90,7 @@ mod AnyAIDecoderTest {
|
||||
#[test]
|
||||
fn testAnyAIDecoder3() {
|
||||
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";
|
||||
|
||||
@@ -111,7 +99,7 @@ mod AnyAIDecoderTest {
|
||||
|
||||
#[test]
|
||||
fn testAnyAIDecodernumericFNC1secondDigit() {
|
||||
let data = format!("{}{}{}", HEADER, NUMERIC10, NUMERIC1_FNC1);
|
||||
let data = format!("{HEADER}{NUMERIC10}{NUMERIC1_FNC1}");
|
||||
let expected = "(10)1";
|
||||
|
||||
assertCorrectBinaryString(&data, expected);
|
||||
@@ -120,8 +108,7 @@ mod AnyAIDecoderTest {
|
||||
#[test]
|
||||
fn testAnyAIDecoderalphaFNC1() {
|
||||
let data = format!(
|
||||
"{}{}{}{}{}",
|
||||
HEADER, NUMERIC10, NUMERIC2ALPHA, ALPHA_A, ALPHA_FNC1
|
||||
"{HEADER}{NUMERIC10}{NUMERIC2ALPHA}{ALPHA_A}{ALPHA_FNC1}"
|
||||
);
|
||||
let expected = "(10)A";
|
||||
|
||||
@@ -131,8 +118,7 @@ mod AnyAIDecoderTest {
|
||||
#[test]
|
||||
fn testAnyAIDecoder646FNC1() {
|
||||
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";
|
||||
|
||||
|
||||
@@ -215,13 +215,13 @@ fn processFixedAI(
|
||||
.take(fieldSize)
|
||||
.collect(); //rawInformation.substring(aiSize, 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)?;
|
||||
|
||||
Ok(if parsedAI.is_empty() {
|
||||
result
|
||||
} else {
|
||||
format!("{}{}", result, parsedAI)
|
||||
format!("{result}{parsedAI}")
|
||||
})
|
||||
}
|
||||
|
||||
@@ -237,13 +237,13 @@ fn processVariableAI(
|
||||
.min(aiSize + variableFieldSize);
|
||||
let field: String = rawInformation.chars().skip(aiSize).take(maxSize).collect(); // (aiSize, maxSize);
|
||||
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)?;
|
||||
|
||||
Ok(if parsedAI.is_empty() {
|
||||
result
|
||||
} else {
|
||||
format!("{}{}", result, parsedAI)
|
||||
format!("{result}{parsedAI}")
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -445,8 +445,7 @@ impl<'a> GeneralAppIdDecoder<'_> {
|
||||
62 => '/',
|
||||
_ => {
|
||||
return Err(Exceptions::IllegalStateException(Some(format!(
|
||||
"Decoding invalid alphanumeric value: {}",
|
||||
sixBitValue
|
||||
"Decoding invalid alphanumeric value: {sixBitValue}"
|
||||
))))
|
||||
}
|
||||
};
|
||||
|
||||
@@ -68,7 +68,7 @@ impl Display for ExpandedRow {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "{{ ")?;
|
||||
for p in &self.pairs {
|
||||
write!(f, "{}", p)?;
|
||||
write!(f, "{p}")?;
|
||||
}
|
||||
write!(f, " }}") //{:?} }} " , self.pairs )
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ fn testDecodeRow2binary22() {
|
||||
}
|
||||
|
||||
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 binaryMap = BinaryBitmap::new(Rc::new(GlobalHistogramBinarizer::new(Box::new(
|
||||
|
||||
@@ -68,7 +68,7 @@ fn testDecodeRow2result2() {
|
||||
}
|
||||
|
||||
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 binaryMap = BinaryBitmap::new(Rc::new(GlobalHistogramBinarizer::new(Box::new(
|
||||
|
||||
@@ -181,7 +181,7 @@ fn testDecodeRow2string32() {
|
||||
}
|
||||
|
||||
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 binaryMap = BinaryBitmap::new(Rc::new(GlobalHistogramBinarizer::new(Box::new(
|
||||
|
||||
@@ -172,8 +172,7 @@ fn testDecodeDataCharacter() {
|
||||
|
||||
fn readImage(fileName: &str) -> image::DynamicImage {
|
||||
image::open(format!(
|
||||
"test_resources/blackbox/rssexpanded-1/{}",
|
||||
fileName
|
||||
"test_resources/blackbox/rssexpanded-1/{fileName}"
|
||||
))
|
||||
.unwrap()
|
||||
// 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};
|
||||
|
||||
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")
|
||||
}
|
||||
|
||||
@@ -49,13 +49,12 @@ impl Writer for UPCAWriter {
|
||||
) -> Result<crate::common::BitMatrix, crate::Exceptions> {
|
||||
if format != &BarcodeFormat::UPC_A {
|
||||
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||
"Can only encode UPC-A, but got {:?}",
|
||||
format
|
||||
"Can only encode UPC-A, but got {format:?}"
|
||||
))));
|
||||
}
|
||||
// Transform a UPC-A code into the equivalent EAN-13 code and write it that way
|
||||
self.0.encode_with_hints(
|
||||
&format!("0{}", contents),
|
||||
&format!("0{contents}"),
|
||||
&BarcodeFormat::EAN_13,
|
||||
width,
|
||||
height,
|
||||
|
||||
@@ -69,8 +69,7 @@ impl OneDimensionalCodeWriter for UPCEWriter {
|
||||
// }},
|
||||
_ => {
|
||||
return Err(Exceptions::IllegalArgumentException(Some(format!(
|
||||
"Requested contents should be 7 or 8 digits long, but got {}",
|
||||
length
|
||||
"Requested contents should be 7 or 8 digits long, but got {length}"
|
||||
))))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,11 +209,11 @@ impl UPCEANExtension5Support {
|
||||
let unitsString = (rawAmount / 100).to_string();
|
||||
let hundredths = rawAmount % 100;
|
||||
let hundredthsString = if hundredths < 10 {
|
||||
format!("0{}", hundredths)
|
||||
format!("0{hundredths}")
|
||||
} else {
|
||||
hundredths.to_string()
|
||||
};
|
||||
|
||||
Some(format!("{}{}.{}", currency, unitsString, hundredthsString))
|
||||
Some(format!("{currency}{unitsString}.{hundredthsString}"))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -304,7 +304,7 @@ pub trait UPCEANReader: OneDReader {
|
||||
|
||||
decodeRXingResult.putMetadata(
|
||||
RXingResultMetadataType::SYMBOLOGY_IDENTIFIER,
|
||||
RXingResultMetadataValue::SymbologyIdentifier(format!("]E{}", symbologyIdentifier)),
|
||||
RXingResultMetadataValue::SymbologyIdentifier(format!("]E{symbologyIdentifier}")),
|
||||
);
|
||||
|
||||
Ok(decodeRXingResult)
|
||||
|
||||
Reference in New Issue
Block a user