### Question:
MathUtils { public static int nextPowerOfTwo(final int x) { return (int) Math.pow(2, Math.ceil(log2(x))); } private  MathUtils(); static boolean isPowerOfTwo(final int value); static int nextPowerOfTwo(final int x); static double log2(final double x);  }### Answer:
@Test public void testNextPowerOfTwo() { assertEquals(MathUtils.nextPowerOfTwo(0), 0); assertEquals(MathUtils.nextPowerOfTwo(1), 1); assertEquals(MathUtils.nextPowerOfTwo(2), 2); assertEquals(MathUtils.nextPowerOfTwo(3), 4); assertEquals(MathUtils.nextPowerOfTwo(4), 4); assertEquals(MathUtils.nextPowerOfTwo(5), 8); assertEquals(MathUtils.nextPowerOfTwo(7), 8); assertEquals(MathUtils.nextPowerOfTwo(8), 8); assertEquals(MathUtils.nextPowerOfTwo(9), 16); assertEquals(MathUtils.nextPowerOfTwo(15), 16); assertEquals(MathUtils.nextPowerOfTwo(16), 16); assertEquals(MathUtils.nextPowerOfTwo(17), 32); assertEquals(MathUtils.nextPowerOfTwo(31), 32); assertEquals(MathUtils.nextPowerOfTwo(32), 32); assertEquals(MathUtils.nextPowerOfTwo(33), 64); assertEquals(MathUtils.nextPowerOfTwo(63), 64); assertEquals(MathUtils.nextPowerOfTwo(64), 64); assertEquals(MathUtils.nextPowerOfTwo(65), 128); assertEquals(MathUtils.nextPowerOfTwo(127), 128); assertEquals(MathUtils.nextPowerOfTwo(128), 128); assertEquals(MathUtils.nextPowerOfTwo(129), 256); assertEquals(MathUtils.nextPowerOfTwo(255), 256); assertEquals(MathUtils.nextPowerOfTwo(256), 256); assertEquals(MathUtils.nextPowerOfTwo(257), 512); assertEquals(MathUtils.nextPowerOfTwo(511), 512); assertEquals(MathUtils.nextPowerOfTwo(512), 512); assertEquals(MathUtils.nextPowerOfTwo(513), 1024); assertEquals(MathUtils.nextPowerOfTwo(1023), 1024); assertEquals(MathUtils.nextPowerOfTwo(1024), 1024); assertEquals(MathUtils.nextPowerOfTwo(1025), 2048); }