Skip to content

Commit 0a7a268

Browse files
committed
Resolved with Suggested changes
1 parent 7405568 commit 0a7a268

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@
2828
</dependencyManagement>
2929

3030
<dependencies>
31+
<dependency>
32+
<groupId>org.junit.jupiter</groupId>
33+
<artifactId>junit-jupiter-api</artifactId>
34+
<version>5.8.2</version>
35+
<scope>test</scope>
36+
</dependency>
3137
<dependency>
3238
<groupId>org.junit.jupiter</groupId>
3339
<artifactId>junit-jupiter</artifactId>

src/main/java/com/thealgorithms/maths/HeronsFormula.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public final class HeronsFormula {
1414
* here s is called semi-perimeter and it is the half of the perimeter (i.e; s = (s1+s2+s3)/2)
1515
* @author satyabarghav
1616
*/
17-
private HeronsFormula(){
17+
private HeronsFormula() {
1818
}
1919
public static double Herons(final double a, final double b, final double c) {
2020
if (!(a + b > c && b + c > a && c + a > b)) {
@@ -24,7 +24,4 @@ public static double Herons(final double a, final double b, final double c) {
2424
return Math.sqrt((s) * (s - a) * (s - b) * (s - c));
2525
}
2626
}
27-
public static void main(String[] args){
28-
System.out.println(Herons(1, 2, 3));
29-
}
3027
}

src/test/java/com/thealgorithms/maths/HeronsFormulaTest.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.thealgorithms.maths;
22

3-
import org.junit.jupiter.api.Assertions;
4-
import org.junit.jupiter.api.Test;
3+
import org.junit.jupiter.api.*;
54

65
public class HeronsFormulaTest {
76

@@ -26,9 +25,7 @@ void test4() {
2625
}
2726

2827
@Test
29-
void test5() {
30-
assertThrows(IllegalArgumentException.class, () -> {
31-
HeronsFormula.calculateArea(1, 2, 3);
32-
});
28+
public void testCalculateAreaWithInvalidInput() {
29+
Assertions.assertThrows(IllegalArgumentException.class, () -> { HeronsFormula.Herons(1, 2, 3); });
3330
}
3431
}

0 commit comments

Comments
 (0)