BIUtil { public static boolean isIn20PercentRange(BigInteger first, BigInteger second) { BigInteger five = BigInteger.valueOf(5); BigInteger limit = first.add(first.divide(five)); return !isMoreThan(second, limit); }  static boolean isZero(BigInteger value); static boolean isEqual(BigInteger valueA, BigInteger valueB); static boolean isNotEqual(BigInteger valueA, BigInteger valueB); static boolean isLessThan(BigInteger valueA, BigInteger valueB); static boolean isMoreThan(BigInteger valueA, BigInteger valueB); static BigInteger sum(BigInteger valueA, BigInteger valueB); static BigInteger toBI(byte[] data); static BigInteger toBI(long data); static boolean isPositive(BigInteger value); static boolean isCovers(BigInteger covers, BigInteger value); static boolean isNotCovers(BigInteger covers, BigInteger value); static void transfer(Repository repository, byte[] fromAddr, byte[] toAddr, BigInteger value); static boolean exitLong(BigInteger value); static boolean isIn20PercentRange(BigInteger first, BigInteger second); static BigInteger max(BigInteger first, BigInteger second); static int addSafely(int a, int b);  }
@Test public void testIsIn20PercentRange() { assertTrue(isIn20PercentRange(BigInteger.valueOf(20000), BigInteger.valueOf(24000))); assertTrue(isIn20PercentRange(BigInteger.valueOf(24000), BigInteger.valueOf(20000))); assertFalse(isIn20PercentRange(BigInteger.valueOf(20000), BigInteger.valueOf(25000))); assertTrue(isIn20PercentRange(BigInteger.valueOf(20), BigInteger.valueOf(24))); assertTrue(isIn20PercentRange(BigInteger.valueOf(24), BigInteger.valueOf(20))); assertFalse(isIn20PercentRange(BigInteger.valueOf(20), BigInteger.valueOf(25))); assertTrue(isIn20PercentRange(BigInteger.ZERO, BigInteger.ZERO)); assertFalse(isIn20PercentRange(BigInteger.ZERO, BigInteger.ONE)); assertTrue(isIn20PercentRange(BigInteger.ONE, BigInteger.ZERO)); }
@Test public void test1() { assertFalse(isIn20PercentRange(BigInteger.ONE, BigInteger.valueOf(5))); assertTrue(isIn20PercentRange(BigInteger.valueOf(5), BigInteger.ONE)); assertTrue(isIn20PercentRange(BigInteger.valueOf(5), BigInteger.valueOf(6))); assertFalse(isIn20PercentRange(BigInteger.valueOf(5), BigInteger.valueOf(7))); }