This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -290,6 +290,17 @@ macro_rules! int_module {
290290 assert_eq!( r. saturating_pow( 0 ) , 1 as $T) ;
291291 }
292292
293+ #[ test]
294+ fn test_isqrt( ) {
295+ assert_eq!( $T:: MIN . checked_isqrt( ) , None ) ;
296+ assert_eq!( ( -1 as $T) . checked_isqrt( ) , None ) ;
297+ assert_eq!( ( 0 as $T) . isqrt( ) , 0 as $T) ;
298+ assert_eq!( ( 1 as $T) . isqrt( ) , 1 as $T) ;
299+ assert_eq!( ( 2 as $T) . isqrt( ) , 1 as $T) ;
300+ assert_eq!( ( 99 as $T) . isqrt( ) , 9 as $T) ;
301+ assert_eq!( ( 100 as $T) . isqrt( ) , 10 as $T) ;
302+ }
303+
293304 #[ test]
294305 fn test_div_floor( ) {
295306 let a: $T = 8 ;
Original file line number Diff line number Diff line change @@ -206,6 +206,16 @@ macro_rules! uint_module {
206206 assert_eq!( r. saturating_pow( 2 ) , MAX ) ;
207207 }
208208
209+ #[ test]
210+ fn test_isqrt( ) {
211+ assert_eq!( ( 0 as $T) . isqrt( ) , 0 as $T) ;
212+ assert_eq!( ( 1 as $T) . isqrt( ) , 1 as $T) ;
213+ assert_eq!( ( 2 as $T) . isqrt( ) , 1 as $T) ;
214+ assert_eq!( ( 99 as $T) . isqrt( ) , 9 as $T) ;
215+ assert_eq!( ( 100 as $T) . isqrt( ) , 10 as $T) ;
216+ assert_eq!( $T:: MAX . isqrt( ) , ( 1 << ( $T:: BITS / 2 ) ) - 1 ) ;
217+ }
218+
209219 #[ test]
210220 fn test_div_floor( ) {
211221 assert_eq!( ( 8 as $T) . div_floor( 3 ) , 2 ) ;
You can’t perform that action at this time.
0 commit comments