Now with tests for the basic algorithms.

This commit is contained in:
2018-09-28 17:48:35 -05:00
parent 3b68363b49
commit 304d009a67
95 changed files with 271012 additions and 270361 deletions

View File

@@ -89,4 +89,44 @@ macro_rules! shift_impls
}
}
//shift_impls!(U192, 3);
#[cfg(test)]
macro_rules! generate_shiftl_tests {
($name: ident, $lname: ident) => {
#[test]
fn $lname() {
let fname = format!("testdata/shiftl/{}.tests", stringify!($name));
run_test(fname.to_string(), 3, |case| {
let (neg0, abytes) = case.get("a").unwrap();
let (neg1, lbytes) = case.get("l").unwrap();
let (neg2, rbytes) = case.get("r").unwrap();
assert!(!neg0 && !neg1 && !neg2);
let a = $name::from_bytes(abytes);
let l = $name::from_bytes(lbytes);
let r = $name::from_bytes(rbytes);
assert_eq!(r, a << usize::from(l));
});
}
};
}
#[cfg(test)]
macro_rules! generate_shiftr_tests {
($name: ident, $lname: ident) => {
#[test]
fn $lname() {
let fname = format!("testdata/shiftr/{}.tests", stringify!($name));
run_test(fname.to_string(), 3, |case| {
let (neg0, abytes) = case.get("a").unwrap();
let (neg1, lbytes) = case.get("l").unwrap();
let (neg2, rbytes) = case.get("r").unwrap();
assert!(!neg0 && !neg1 && !neg2);
let a = $name::from_bytes(abytes);
let l = $name::from_bytes(lbytes);
let r = $name::from_bytes(rbytes);
assert_eq!(r, a >> usize::from(l));
});
}
};
}