package tests; import static org.junit.Assert.*; import org.junit.Test; public class MathTest { private static final double DELTA = 0.001; // Ensure that the absolute value of a negative int is calculated correctly. @Test public void testAbsIntNegative() { int res = Math.abs(-5); assertEquals(5, res); } // Ensure that the absolute value of a positive number is calculated correctly. @Test public void testAbsIntPositive() { int abs = Math.abs(5); assertEquals(5, abs); } // Ensure that the absolute value of zero is calculated correctly. @Test public void testAbsIntZero() { int res = Math.abs(0); assertEquals(0, res); } // Ensure that ceil rounds up for a negative number. @Test public void testCeilNegative() { double res = Math.ceil(-5.25); assertEquals(-6, res, DELTA); } // Ensure that ceil rounds up for a positive number. @Test public void testCeilPositive() { double res = Math.ceil(5.25); assertEquals(6, res, DELTA); } // Ensure that sqrt returns the correct value for a perfect square @Test public void testSqrtPerfectSquare() { double res = Math.sqrt(25); assertEquals(4, res, DELTA); } }