@@ -66,17 +66,17 @@ public void testCeilingPowerOfTwo() {
6666 for (BigInteger x : POSITIVE_BIGINTEGER_CANDIDATES ) {
6767 BigInteger result = BigIntegerMath .ceilingPowerOfTwo (x );
6868 assertTrue (BigIntegerMath .isPowerOfTwo (result ));
69- assertTrue (result . compareTo ( x ) >= 0 );
70- assertTrue (result . compareTo (x .add (x )) < 0 );
69+ assertThat (result ). isAtLeast ( x );
70+ assertThat (result ). isLessThan (x .add (x ));
7171 }
7272 }
7373
7474 public void testFloorPowerOfTwo () {
7575 for (BigInteger x : POSITIVE_BIGINTEGER_CANDIDATES ) {
7676 BigInteger result = BigIntegerMath .floorPowerOfTwo (x );
7777 assertTrue (BigIntegerMath .isPowerOfTwo (result ));
78- assertTrue (result . compareTo ( x ) <= 0 );
79- assertTrue (result .add (result ). compareTo ( x ) > 0 );
78+ assertThat (result ). isAtMost ( x );
79+ assertThat (result .add (result )). isGreaterThan ( x );
8080 }
8181 }
8282
@@ -135,8 +135,8 @@ public void testLog2Floor() {
135135 for (BigInteger x : POSITIVE_BIGINTEGER_CANDIDATES ) {
136136 for (RoundingMode mode : asList (FLOOR , DOWN )) {
137137 int result = BigIntegerMath .log2 (x , mode );
138- assertTrue (ZERO .setBit (result ). compareTo ( x ) <= 0 );
139- assertTrue (ZERO .setBit (result + 1 ). compareTo ( x ) > 0 );
138+ assertThat (ZERO .setBit (result )). isAtMost ( x );
139+ assertThat (ZERO .setBit (result + 1 )). isGreaterThan ( x );
140140 }
141141 }
142142 }
@@ -145,7 +145,7 @@ public void testLog2Ceiling() {
145145 for (BigInteger x : POSITIVE_BIGINTEGER_CANDIDATES ) {
146146 for (RoundingMode mode : asList (CEILING , UP )) {
147147 int result = BigIntegerMath .log2 (x , mode );
148- assertTrue (ZERO .setBit (result ). compareTo ( x ) >= 0 );
148+ assertThat (ZERO .setBit (result )). isAtLeast ( x );
149149 assertTrue (result == 0 || ZERO .setBit (result - 1 ).compareTo (x ) < 0 );
150150 }
151151 }
@@ -170,7 +170,7 @@ public void testLog2HalfUp() {
170170 int result = BigIntegerMath .log2 (x , HALF_UP );
171171 BigInteger x2 = x .pow (2 );
172172 // x^2 < 2^(2 * result + 1), or else we would have rounded up
173- assertTrue (ZERO .setBit (2 * result + 1 ). compareTo (x2 ) > 0 );
173+ assertThat (ZERO .setBit (2 * result + 1 )). isGreaterThan (x2 );
174174 // x^2 >= 2^(2 * result - 1), or else we would have rounded down
175175 assertTrue (result == 0 || ZERO .setBit (2 * result - 1 ).compareTo (x2 ) <= 0 );
176176 }
@@ -181,7 +181,7 @@ public void testLog2HalfDown() {
181181 int result = BigIntegerMath .log2 (x , HALF_DOWN );
182182 BigInteger x2 = x .pow (2 );
183183 // x^2 <= 2^(2 * result + 1), or else we would have rounded up
184- assertTrue (ZERO .setBit (2 * result + 1 ). compareTo (x2 ) >= 0 );
184+ assertThat (ZERO .setBit (2 * result + 1 )). isAtLeast (x2 );
185185 // x^2 > 2^(2 * result - 1), or else we would have rounded down
186186 assertTrue (result == 0 || ZERO .setBit (2 * result - 1 ).compareTo (x2 ) < 0 );
187187 }
@@ -218,8 +218,8 @@ public void testLog10Floor() {
218218 for (BigInteger x : POSITIVE_BIGINTEGER_CANDIDATES ) {
219219 for (RoundingMode mode : asList (FLOOR , DOWN )) {
220220 int result = BigIntegerMath .log10 (x , mode );
221- assertTrue (TEN .pow (result ). compareTo ( x ) <= 0 );
222- assertTrue (TEN .pow (result + 1 ). compareTo ( x ) > 0 );
221+ assertThat (TEN .pow (result )). isAtMost ( x );
222+ assertThat (TEN .pow (result + 1 )). isGreaterThan ( x );
223223 }
224224 }
225225 }
@@ -229,7 +229,7 @@ public void testLog10Ceiling() {
229229 for (BigInteger x : POSITIVE_BIGINTEGER_CANDIDATES ) {
230230 for (RoundingMode mode : asList (CEILING , UP )) {
231231 int result = BigIntegerMath .log10 (x , mode );
232- assertTrue (TEN .pow (result ). compareTo ( x ) >= 0 );
232+ assertThat (TEN .pow (result )). isAtLeast ( x );
233233 assertTrue (result == 0 || TEN .pow (result - 1 ).compareTo (x ) < 0 );
234234 }
235235 }
@@ -256,7 +256,7 @@ public void testLog10HalfUp() {
256256 int result = BigIntegerMath .log10 (x , HALF_UP );
257257 BigInteger x2 = x .pow (2 );
258258 // x^2 < 10^(2 * result + 1), or else we would have rounded up
259- assertTrue (TEN .pow (2 * result + 1 ). compareTo (x2 ) > 0 );
259+ assertThat (TEN .pow (2 * result + 1 )). isGreaterThan (x2 );
260260 // x^2 >= 10^(2 * result - 1), or else we would have rounded down
261261 assertTrue (result == 0 || TEN .pow (2 * result - 1 ).compareTo (x2 ) <= 0 );
262262 }
@@ -268,7 +268,7 @@ public void testLog10HalfDown() {
268268 int result = BigIntegerMath .log10 (x , HALF_DOWN );
269269 BigInteger x2 = x .pow (2 );
270270 // x^2 <= 10^(2 * result + 1), or else we would have rounded up
271- assertTrue (TEN .pow (2 * result + 1 ). compareTo (x2 ) >= 0 );
271+ assertThat (TEN .pow (2 * result + 1 )). isAtLeast (x2 );
272272 // x^2 > 10^(2 * result - 1), or else we would have rounded down
273273 assertTrue (result == 0 || TEN .pow (2 * result - 1 ).compareTo (x2 ) < 0 );
274274 }
@@ -314,9 +314,9 @@ public void testSqrtFloor() {
314314 for (BigInteger x : POSITIVE_BIGINTEGER_CANDIDATES ) {
315315 for (RoundingMode mode : asList (FLOOR , DOWN )) {
316316 BigInteger result = BigIntegerMath .sqrt (x , mode );
317- assertTrue (result . compareTo (ZERO ) > 0 );
318- assertTrue (result .pow (2 ). compareTo ( x ) <= 0 );
319- assertTrue (result .add (ONE ).pow (2 ). compareTo ( x ) > 0 );
317+ assertThat (result ). isGreaterThan (ZERO );
318+ assertThat (result .pow (2 )). isAtMost ( x );
319+ assertThat (result .add (ONE ).pow (2 )). isGreaterThan ( x );
320320 }
321321 }
322322 }
@@ -326,8 +326,8 @@ public void testSqrtCeiling() {
326326 for (BigInteger x : POSITIVE_BIGINTEGER_CANDIDATES ) {
327327 for (RoundingMode mode : asList (CEILING , UP )) {
328328 BigInteger result = BigIntegerMath .sqrt (x , mode );
329- assertTrue (result . compareTo (ZERO ) > 0 );
330- assertTrue (result .pow (2 ). compareTo ( x ) >= 0 );
329+ assertThat (result ). isGreaterThan (ZERO );
330+ assertThat (result .pow (2 )). isAtLeast ( x );
331331 assertTrue (result .signum () == 0 || result .subtract (ONE ).pow (2 ).compareTo (x ) < 0 );
332332 }
333333 }
@@ -357,7 +357,7 @@ public void testSqrtHalfUp() {
357357 BigInteger x4 = x .shiftLeft (2 );
358358 // sqrt(x) < result + 0.5, so 4 * x < (result + 0.5)^2 * 4
359359 // (result + 0.5)^2 * 4 = (result^2 + result)*4 + 1
360- assertTrue ( x4 . compareTo ( plusHalfSquared ) < 0 );
360+ assertThat ( plusHalfSquared ). isGreaterThan ( x4 );
361361 BigInteger minusHalfSquared = result .pow (2 ).subtract (result ).shiftLeft (2 ).add (ONE );
362362 // sqrt(x) > result - 0.5, so 4 * x > (result - 0.5)^2 * 4
363363 // (result - 0.5)^2 * 4 = (result^2 - result)*4 + 1
@@ -373,7 +373,7 @@ public void testSqrtHalfDown() {
373373 BigInteger x4 = x .shiftLeft (2 );
374374 // sqrt(x) <= result + 0.5, so 4 * x <= (result + 0.5)^2 * 4
375375 // (result + 0.5)^2 * 4 = (result^2 + result)*4 + 1
376- assertTrue ( x4 . compareTo ( plusHalfSquared ) <= 0 );
376+ assertThat ( plusHalfSquared ). isAtLeast ( x4 );
377377 BigInteger minusHalfSquared = result .pow (2 ).subtract (result ).shiftLeft (2 ).add (ONE );
378378 // sqrt(x) > result - 0.5, so 4 * x > (result - 0.5)^2 * 4
379379 // (result - 0.5)^2 * 4 = (result^2 - result)*4 + 1
0 commit comments