diff options
| author | Yuval Adam <_@yuv.al> | 2019-03-19 22:00:11 +0200 |
|---|---|---|
| committer | Yuval Adam <_@yuv.al> | 2019-03-19 22:00:11 +0200 |
| commit | 11c492aeaff0aff251690fd2378e0cd7467cb416 (patch) | |
| tree | 3f0ce2a429f334dd9e95536d70cbc2c75077ebd5 | |
| parent | cda9836c9ddbd538cfcde647ac6d284dd75f88a0 (diff) | |
Fix bytes in tests - pass!
| -rw-r--r-- | src/lib.rs | 14 |
1 files changed, 6 insertions, 8 deletions
@@ -12,9 +12,7 @@ impl BCH { fn decode(&mut self, msg: &[u8], ecc: &[u8], errloc: &mut[u32]) -> i32 { let err = unsafe { - ffi::decode_bch( - &mut self.0, msg.as_ptr(), msg.len() as u32, - null(), null(), null(), errloc.as_mut_ptr()) + ffi::decodebits_bch(&mut self.0, msg.as_ptr(), ecc.as_ptr(), errloc.as_mut_ptr()) }; err } @@ -28,8 +26,8 @@ mod tests { #[test] fn test_decode() { let mut bch = BCH::init(5, 2, 37); - let msg: [u8; 11] = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; - let ecc: [u8; 5] = [0x11, 0x10, 0x11, 0x01, 0x00]; + let msg: [u8; 21] = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; + let ecc: [u8; 10] = [1, 1, 1, 0, 1, 1, 0, 1, 0, 0]; let mut errloc: [u32; 2] = [0, 0]; bch.decode(&msg, &ecc, &mut errloc); assert_eq!(errloc[0], 0); @@ -39,11 +37,11 @@ mod tests { #[test] fn test_decode_err() { let mut bch = BCH::init(5, 2, 37); - let msg: [u8; 11] = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; - let ecc: [u8; 5] = [0x11, 0x10, 0x11, 0x01, 0x01]; + let msg: [u8; 21] = [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; + let ecc: [u8; 10] = [1, 1, 1, 0, 1, 1, 0, 1, 0, 1]; let mut errloc: [u32; 2] = [0, 0]; bch.decode(&msg, &ecc, &mut errloc); - assert_eq!(errloc[0], 0); + assert_eq!(errloc[0], 30); assert_eq!(errloc[1], 0); } } |
