@@ -309,27 +309,22 @@ impl Integer for UnifiedNum {
309309 UnifiedNum :: div_floor ( self , other)
310310 }
311311
312- // TODO: Check math and write tests
313312 fn mod_floor ( & self , other : & Self ) -> Self {
314313 self . 0 . mod_floor ( & other. 0 ) . into ( )
315314 }
316315
317- // TODO: Check math and write tests
318316 fn gcd ( & self , other : & Self ) -> Self {
319317 self . 0 . gcd ( & other. 0 ) . into ( )
320318 }
321319
322- // TODO: Check math and write tests
323320 fn lcm ( & self , other : & Self ) -> Self {
324321 self . 0 . lcm ( & other. 0 ) . into ( )
325322 }
326323
327- // TODO: Check math and write tests
328324 fn divides ( & self , other : & Self ) -> bool {
329325 self . 0 . divides ( & other. 0 )
330326 }
331327
332- // TODO: Check math and write tests
333328 fn is_multiple_of ( & self , other : & Self ) -> bool {
334329 self . 0 . is_multiple_of ( & other. 0 )
335330 }
@@ -342,7 +337,6 @@ impl Integer for UnifiedNum {
342337 !self . is_even ( )
343338 }
344339
345- // TODO: Check math and write tests
346340 fn div_rem ( & self , other : & Self ) -> ( Self , Self ) {
347341 let ( quotient, remainder) = self . 0 . div_rem ( & other. 0 ) ;
348342
@@ -961,6 +955,69 @@ mod test {
961955 ) ;
962956 }
963957 }
958+
959+ #[ test]
960+ fn test_unified_num_mod_floor_gcd_lcm_divides_is_multiple_of_div_rem ( ) {
961+ // Mod floor
962+ {
963+ assert_eq ! (
964+ ( UnifiedNum :: from_u64( 8 ) ) . mod_floor( & UnifiedNum :: from_u64( 3 ) ) ,
965+ UnifiedNum :: from_u64( 2 )
966+ ) ;
967+ assert_eq ! (
968+ ( UnifiedNum :: from_u64( 1 ) ) . mod_floor( & UnifiedNum :: from_u64( 2 ) ) ,
969+ UnifiedNum :: from_u64( 1 )
970+ ) ;
971+ }
972+
973+ // GCD
974+ {
975+ assert_eq ! (
976+ UnifiedNum :: from_u64( 6 ) . gcd( & UnifiedNum :: from_u64( 8 ) ) ,
977+ UnifiedNum :: from_u64( 2 )
978+ ) ;
979+ assert_eq ! (
980+ UnifiedNum :: from_u64( 7 ) . gcd( & UnifiedNum :: from_u64( 3 ) ) ,
981+ UnifiedNum :: from_u64( 1 )
982+ ) ;
983+ }
984+
985+ // LCM
986+ {
987+ assert_eq ! (
988+ UnifiedNum :: from_u64( 7 ) . lcm( & UnifiedNum :: from_u64( 3 ) ) ,
989+ UnifiedNum :: from_u64( 21 )
990+ ) ;
991+ assert_eq ! (
992+ UnifiedNum :: from_u64( 2 ) . lcm( & UnifiedNum :: from_u64( 4 ) ) ,
993+ UnifiedNum :: from_u64( 4 )
994+ ) ;
995+ }
996+
997+ // Is multiple of
998+ {
999+ assert_eq ! (
1000+ UnifiedNum :: from_u64( 9 ) . is_multiple_of( & UnifiedNum :: from_u64( 3 ) ) ,
1001+ true
1002+ ) ;
1003+ assert_eq ! (
1004+ UnifiedNum :: from_u64( 3 ) . is_multiple_of( & UnifiedNum :: from_u64( 9 ) ) ,
1005+ false
1006+ ) ;
1007+ }
1008+
1009+ // Div rem
1010+ {
1011+ assert_eq ! (
1012+ ( UnifiedNum :: from_u64( 8 ) ) . div_rem( & UnifiedNum :: from_u64( 3 ) ) ,
1013+ ( UnifiedNum :: from_u64( 2 ) , UnifiedNum :: from_u64( 2 ) )
1014+ ) ;
1015+ assert_eq ! (
1016+ ( UnifiedNum :: from_u64( 1 ) ) . div_rem( & UnifiedNum :: from_u64( 2 ) ) ,
1017+ ( UnifiedNum :: from_u64( 0 ) , UnifiedNum :: from_u64( 1 ) )
1018+ ) ;
1019+ }
1020+ }
9641021}
9651022
9661023#[ cfg( feature = "postgres" ) ]
0 commit comments