summaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
authorYuval Adam <_@yuv.al>2019-03-29 22:00:21 +0100
committerYuval Adam <_@yuv.al>2019-03-29 22:00:21 +0100
commit3fe62cbe909791b4b3d125d41f00708b1422243f (patch)
treed9c3843c7e4499bd669aa1310ca275e5fea4155a /src/lib.rs
parentf9b01e24f52cac276ba0aaebe1bdc791b26e8aa4 (diff)
Split BCH::init_with_poly
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/lib.rs b/src/lib.rs
index c5943ee..a3b2370 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -6,7 +6,11 @@ use std::ptr;
struct BCH(ffi::bch_control);
impl BCH {
- fn init(m: i32, t: i32, poly: u32) -> Result<BCH, &'static str> {
+ fn init(m: i32, t: i32) -> Result<BCH, &'static str> {
+ BCH::init_with_poly(m, t, 0)
+ }
+
+ fn init_with_poly(m: i32, t: i32, poly: u32) -> Result<BCH, &'static str> {
unsafe {
let bch = ffi::init_bch(m, t, poly);
if bch == ptr::null_mut() {
@@ -33,7 +37,7 @@ mod tests {
#[test]
fn test_decode() {
- let mut bch = BCH::init(5, 2, 0).unwrap();
+ let mut bch = BCH::init(5, 2).unwrap();
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];
@@ -44,7 +48,7 @@ mod tests {
#[test]
fn test_decode_err() {
- let mut bch = BCH::init(5, 2, 0).unwrap();
+ let mut bch = BCH::init(5, 2).unwrap();
let msg: [u8; 21] = [1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 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];
@@ -55,7 +59,7 @@ mod tests {
#[test]
fn test_sync_codeword() {
- let mut bch = BCH::init(5, 2, 0).unwrap();
+ let mut bch = BCH::init(5, 2).unwrap();
let msg: [u8; 21] = [0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0];
let ecc: [u8; 10] = [1, 0, 1, 1, 1, 0, 1, 1, 0, 0];
let mut errloc: [u32; 2] = [0, 0];
@@ -66,7 +70,7 @@ mod tests {
#[test]
fn test_init_fail() {
- let bch = BCH::init(5, 2, 1897);
+ let bch = BCH::init_with_poly(5, 2, 1897);
assert_eq!(bch.is_err(), true);
}
}