improve test coverage

This commit is contained in:
Solomon Ucko 2022-08-14 23:53:30 -04:00
parent 81739a1311
commit 234fce4b92
2 changed files with 18 additions and 4 deletions

View File

@ -11,8 +11,8 @@ impl PartialEq for SmallUint {
Ordering::Greater => false, Ordering::Greater => false,
Ordering::Less => false, Ordering::Less => false,
Ordering::Equal => { Ordering::Equal => {
let slice1 = unsafe { core::slice::from_raw_parts(r, *s) }; let slice1 = unsafe { core::slice::from_raw_parts(*r, *s) };
let slice2 = unsafe { core::slice::from_raw_parts(i, *j) }; let slice2 = unsafe { core::slice::from_raw_parts(*i, *j) };
for i in 0..*s { for i in 0..*s {
match slice1[s - 1 - i].cmp(&slice2[s - 1 - i]) { match slice1[s - 1 - i].cmp(&slice2[s - 1 - i]) {
Ordering::Less => return false, Ordering::Less => return false,
@ -71,8 +71,8 @@ impl PartialEq for SmallInt {
Ordering::Equal => { Ordering::Equal => {
let us = s.unsigned_abs(); let us = s.unsigned_abs();
let uj = j.unsigned_abs(); let uj = j.unsigned_abs();
let slice1 = unsafe { core::slice::from_raw_parts(r, us) }; let slice1 = unsafe { core::slice::from_raw_parts(*r, us) };
let slice2 = unsafe { core::slice::from_raw_parts(i, uj) }; let slice2 = unsafe { core::slice::from_raw_parts(*i, uj) };
for i in 0..*s { for i in 0..*s {
match slice1[(s - 1 - i) as usize].cmp(&slice2[(s - 1 - i) as usize]) { match slice1[(s - 1 - i) as usize].cmp(&slice2[(s - 1 - i) as usize]) {
Ordering::Less => return false, Ordering::Less => return false,

View File

@ -119,6 +119,20 @@ fn run_tests_i_2<T: Eq + Debug>(
})); }));
} }
#[test]
#[cfg(feature = "num-bigint")]
fn test_convert_biguint() {
run_tests_u_1(|i| BigUint::from(&i), |i| i.clone());
run_tests_u_1(|i| i, |i| SmallUint::from(i));
}
#[test]
#[cfg(feature = "num-bigint")]
fn test_convert_bigint() {
run_tests_i_1(|i| BigInt::from(&i), |i| i.clone());
run_tests_i_1(|i| i, |i| SmallInt::from(i));
}
#[test] #[test]
#[cfg(feature = "num-bigint")] #[cfg(feature = "num-bigint")]
fn test_cmp_u() { fn test_cmp_u() {