Code refactor for AbsoluteMax improvements (#3020)

Fix #3019

Co-authored-by: Yang Libin <szuyanglb@outlook.com>
This commit is contained in:
Cristiano Jesus
2022-04-20 09:15:30 +01:00
committed by GitHub
parent 02375e0683
commit 64b624efb2
2 changed files with 41 additions and 24 deletions

View File

@ -0,0 +1,21 @@
package com.thealgorithms.maths;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
public class AbsoluteMaxTest {
@Test
void testGetMaxValue() {
assertEquals(16, AbsoluteMax.getMaxValue(-2, 0, 16));
assertEquals(-10, AbsoluteMax.getMaxValue(3, -10, -2));
}
@Test
void testGetMaxValueWithNoArguments() {
Exception exception = assertThrows(IllegalArgumentException.class, () -> AbsoluteMax.getMaxValue());
assertEquals("Numbers array cannot be empty", exception.getMessage());
}
}