@@ -20,6 +20,49 @@ namespace Neo.Extensions.Tests
2020 [ TestClass ]
2121 public class UT_BigIntegerExtensions
2222 {
23+ [ TestMethod ]
24+ public void CeilingDivide_DividesExactly ( )
25+ {
26+ var result = BigIntegerExtensions . CeilingDivide ( 9 , 3 ) ;
27+ Assert . AreEqual ( 3 , result ) ;
28+ }
29+
30+ [ TestMethod ]
31+ public void CeilingDivide_RoundsUp ( )
32+ {
33+ var result = BigIntegerExtensions . CeilingDivide ( 10 , 3 ) ;
34+ Assert . AreEqual ( 4 , result ) ;
35+ }
36+
37+ [ TestMethod ]
38+ public void CeilingDivide_LargeNumbers ( )
39+ {
40+ var a = BigInteger . Parse ( "1000000000000000000000000000000000" ) ;
41+ var b = new BigInteger ( 7 ) ;
42+ var result = BigIntegerExtensions . CeilingDivide ( a , b ) ;
43+
44+ Assert . AreEqual ( ( a + b - 1 ) / b , result ) ;
45+ }
46+
47+ [ TestMethod ]
48+ public void CeilingDivide_DivisorOne ( )
49+ {
50+ var result = BigIntegerExtensions . CeilingDivide ( 12345 , 1 ) ;
51+ Assert . AreEqual ( 12345 , result ) ;
52+ }
53+
54+ [ TestMethod ]
55+ public void CeilingDivide_ThrowsOnZeroDivisor ( )
56+ {
57+ Assert . Throws < ArgumentException > ( ( ) => BigIntegerExtensions . CeilingDivide ( 10 , 0 ) ) ;
58+ }
59+
60+ [ TestMethod ]
61+ public void CeilingDivide_ThrowsOnNegativeDivisor ( )
62+ {
63+ Assert . Throws < ArgumentException > ( ( ) => BigIntegerExtensions . CeilingDivide ( 10 , - 5 ) ) ;
64+ }
65+
2366 [ TestMethod ]
2467 public void TestGetLowestSetBit ( )
2568 {
0 commit comments