From 11c492aeaff0aff251690fd2378e0cd7467cb416 Mon Sep 17 00:00:00 2001 From: Yuval Adam <_@yuv.al> Date: Tue, 19 Mar 2019 22:00:11 +0200 Subject: Fix bytes in tests - pass! --- src/lib.rs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs index 0464d92..fec5fc4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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); } } -- cgit v1.3.1