Skip to content

Commit 927ebaf

Browse files
committed
Add edge case tests
1 parent 60fb612 commit 927ebaf

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/uint/sqrt.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ impl<const LIMBS: usize> Uint<LIMBS> {
102102

103103
#[cfg(test)]
104104
mod tests {
105-
use crate::{Limb, U256};
105+
use crate::{Limb, U192, U256};
106106

107107
#[cfg(feature = "rand")]
108108
use {
@@ -120,6 +120,17 @@ mod tests {
120120
half.limbs[i] = Limb::MAX;
121121
}
122122
assert_eq!(U256::MAX.sqrt(), half);
123+
124+
assert_eq!(
125+
U192::from_be_hex("055fa39422bd9f281762946e056535badbf8a6864d45fa3d").sqrt(),
126+
U192::from_be_hex("0000000000000000000000002516f0832a538b2d98869e21")
127+
);
128+
129+
assert_eq!(
130+
U256::from_be_hex("4bb750738e25a8f82940737d94a48a91f8cd918a3679ff90c1a631f2bd6c3597")
131+
.sqrt(),
132+
U256::from_be_hex("000000000000000000000000000000008b3956339e8315cff66eb6107b610075")
133+
);
123134
}
124135

125136
#[test]

0 commit comments

Comments
 (0)