update for shared state and improved performance

This commit is contained in:
Henry Schimke
2023-01-02 16:38:05 -06:00
parent 72f69dd6a0
commit 65f7c4d01b
46 changed files with 505 additions and 359 deletions

View File

@@ -37,7 +37,7 @@ use std::collections::HashMap;
use lazy_static::lazy_static;
use crate::{
common::{BitArray, BitMatrix, BitMatrixTestCase},
common::{BitMatrix, BitMatrixTestCase},
oned::{Code128Reader, OneDReader},
BarcodeFormat, EncodeHintType, EncodeHintValue, EncodingHintDictionary, Exceptions, Writer,
};
@@ -483,18 +483,18 @@ fn encode(toEncode: &str, compact: bool, expectedLoopback: &str) -> Result<BitMa
let encRXingResult =
WRITER.encode_with_hints(toEncode, &BarcodeFormat::CODE_128, 0, 0, &hints)?;
if !expectedLoopback.is_empty() {
let row = encRXingResult.getRow(0, BitArray::new());
let row = encRXingResult.getRow(0);
let rtRXingResult = reader.decodeRow(0, &row, &HashMap::new())?;
let actual = rtRXingResult.getText();
assert_eq!(expectedLoopback, actual);
}
if compact {
//check that what is encoded compactly yields the same on loopback as what was encoded fast.
let row = encRXingResult.getRow(0, BitArray::new());
let row = encRXingResult.getRow(0);
let rtRXingResult = reader.decodeRow(0, &row, &HashMap::new())?;
let actual = rtRXingResult.getText();
let encRXingResultFast = WRITER.encode(toEncode, &BarcodeFormat::CODE_128, 0, 0)?;
let row = encRXingResultFast.getRow(0, BitArray::new());
let row = encRXingResultFast.getRow(0);
let rtRXingResult = reader.decodeRow(0, &row, &HashMap::new())?;
assert_eq!(rtRXingResult.getText(), actual);
}