File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
src/test/java/com/thealgorithms/maths Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -12,4 +12,28 @@ public class AbsoluteValueTest {
1212 void testGetAbsValue () {
1313 Stream .generate (() -> ThreadLocalRandom .current ().nextInt ()).limit (1000 ).forEach (number -> assertEquals (Math .abs (number ), AbsoluteValue .getAbsValue (number )));
1414 }
15+
16+ @ Test
17+ void testZero () {
18+ assertEquals (0 , AbsoluteValue .getAbsValue (0 ));
19+ }
20+
21+ @ Test
22+ void testPositiveNumbers () {
23+ assertEquals (5 , AbsoluteValue .getAbsValue (5 ));
24+ assertEquals (123456 , AbsoluteValue .getAbsValue (123456 ));
25+ assertEquals (Integer .MAX_VALUE , AbsoluteValue .getAbsValue (Integer .MAX_VALUE ));
26+ }
27+
28+ @ Test
29+ void testNegativeNumbers () {
30+ assertEquals (5 , AbsoluteValue .getAbsValue (-5 ));
31+ assertEquals (123456 , AbsoluteValue .getAbsValue (-123456 ));
32+ assertEquals (Integer .MAX_VALUE , AbsoluteValue .getAbsValue (-Integer .MAX_VALUE ));
33+ }
34+
35+ @ Test
36+ void testMinIntEdgeCase () {
37+ assertEquals (Integer .MIN_VALUE , AbsoluteValue .getAbsValue (Integer .MIN_VALUE ));
38+ }
1539}
You can’t perform that action at this time.
0 commit comments