fix issue encoding qrcode digit only data

This commit is contained in:
Henry Schimke
2023-01-07 14:40:31 -06:00
parent 245e14085a
commit 0824d3547a
3 changed files with 13 additions and 2 deletions

View File

@@ -71,6 +71,17 @@ fn testGetAlphanumericCode() {
assert_eq!(-1, encoder::getAlphanumericCode(b'\0' as u32));
}
#[test]
fn test_digits_only() {
let test_data = "374833744734397449";
let data = encoder::encode(test_data, ErrorCorrectionLevel::H).expect("encode");
let decode = crate::qrcode::decoder::decoder::decode_bitmatrix(
&data.getMatrix().as_ref().unwrap().clone().into(),
)
.expect("decode");
assert_eq!(test_data, decode.getText());
}
#[test]
fn testChooseMode() {
// Numeric Mode::