Skip to content
Snippets Groups Projects
Commit 9012d582 authored by Mahboobe Shakeri's avatar Mahboobe Shakeri
Browse files

adding SquareRootTests

parent 34ae2e07
No related branches found
No related tags found
No related merge requests found
......@@ -52,16 +52,32 @@ class CalculatorTest {
}
@Test
void testAddWithMaxValue() {
assertEquals(Integer.MAX_VALUE, calculator.add(Integer.MAX_VALUE, 0), "Adding 0 to Integer.MAX_VALUE should return Integer.MAX_VALUE");
assertEquals(Integer.MAX_VALUE, calculator.add(Integer.MAX_VALUE, 1), "Adding 1 to Integer.MAX_VALUE should return Integer.MAX_VALUE");
void testSquareRootMethodWithPositiveNumber() {
assertEquals(2, calculator.squareRoot(4), "square root method should return 2");
}
@Test
void testSquareRootMethodWithZero(){
assertEquals(0, calculator.squareRoot(0), "square root method should return 0");
}
@Test void testAddWithMaxValueException() {
Exception exception = assertThrows(ArithmeticException.class, () -> {
calculator.add(Integer.MAX_VALUE, Integer.MAX_VALUE);
});
assertTrue(exception.getMessage().contains("integer overflow"));
@Test
void testSquareRootMethodWithNegativeNumber(){
// assertThrows(IllegalArgumentException.class, () -> {calculator.squareRoot(-2);});
assertThrows(IllegalArgumentException.class, () ->{calculator.squareRoot(-2);});
}
// @Test
// void testAddWithMaxValue() {
// assertEquals(Integer.MAX_VALUE, calculator.add(Integer.MAX_VALUE, 0), "Adding 0 to Integer.MAX_VALUE should return Integer.MAX_VALUE");
// assertEquals(Integer.MAX_VALUE, calculator.add(Integer.MAX_VALUE, 1), "Adding 1 to Integer.MAX_VALUE should return Integer.MAX_VALUE");
//
// }
// @Test void testAddWithMaxValueException() {
// Exception exception = assertThrows(ArithmeticException.class, () -> {
// calculator.add(Integer.MAX_VALUE, Integer.MAX_VALUE);
// });
// assertTrue(exception.getMessage().contains("integer overflow"));
// }
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment