Add a quick test to ensure that our GCD algorithm works.

This commit is contained in:
2018-04-14 07:01:59 -07:00
parent 0d08f53d70
commit b1c659087d

View File

@@ -8,7 +8,7 @@ use std::ops::*;
#[derive(Clone,Debug,PartialEq,Eq)] #[derive(Clone,Debug,PartialEq,Eq)]
pub struct SCN { pub struct SCN {
negative: bool, negative: bool,
value: UCN pub(crate) value: UCN
} }
impl SCN { impl SCN {
@@ -308,4 +308,11 @@ mod test {
(- (&a + &b)) == ((- &a) + (- &b)) (- (&a + &b)) == ((- &a) + (- &b))
} }
} }
quickcheck! {
fn egcd_works(a: SCN, b: SCN) -> bool {
let (d, x, y) = a.clone().egcd(b.clone());
((a * x) + (b * y)) == d
}
}
} }