continued porting of test cases

This commit is contained in:
Henry Schimke
2023-04-09 18:25:59 -05:00
parent 8a1d0b3969
commit 1900e1ca57
10 changed files with 364 additions and 214 deletions

View File

@@ -2,7 +2,7 @@ use crate::common::Result;
use crate::qrcode::decoder::ErrorCorrectionLevel;
impl ErrorCorrectionLevel {
pub fn ECLevelFromBits(bits: u8, isMicro: bool) -> Self {
pub fn ECLevelFromBitsSigned(bits: i8, isMicro: bool) -> Self {
if (isMicro) {
let LEVEL_FOR_BITS: [ErrorCorrectionLevel; 8] = [
ErrorCorrectionLevel::L,
@@ -24,4 +24,8 @@ impl ErrorCorrectionLevel {
];
return LEVEL_FOR_BITS[bits as usize & 0x3];
}
pub fn ECLevelFromBits(bits: u8, isMicro: bool) -> Self {
Self::ECLevelFromBitsSigned(bits as i8, isMicro)
}
}

View File

@@ -125,4 +125,9 @@ impl FormatInformation {
pub fn isValid(&self) -> bool {
self.hammingDistance <= 3
}
pub fn cpp_eq(&self, other: &Self) -> bool {
self.data_mask == other.data_mask
&& self.error_correction_level == other.error_correction_level
}
}