summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYuval Adam <_@yuv.al>2019-03-19 22:00:11 +0200
committerYuval Adam <_@yuv.al>2019-03-19 22:00:11 +0200
commit11c492aeaff0aff251690fd2378e0cd7467cb416 (patch)
tree3f0ce2a429f334dd9e95536d70cbc2c75077ebd5 /src
parentcda9836c9ddbd538cfcde647ac6d284dd75f88a0 (diff)
Fix bytes in tests - pass!
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs14
1 files changed, 6 insertions, 8 deletions
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);
}
}