-
Notifications
You must be signed in to change notification settings - Fork 21.1k
Expand file tree
/
Copy pathLinearEquationTest.java
More file actions
35 lines (27 loc) · 1.01 KB
/
LinearEquationTest.java
File metadata and controls
35 lines (27 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package com.thealgorithms.maths;
import static org.junit.jupiter.api.Assertions.assertAll;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import org.junit.jupiter.api.Test;
class LinearEquationTest {
@Test
void testSolveBasic() {
assertEquals(3.0, LinearEquation.solve(2, -6));
}
@Test
void testSolveNegativeResult() {
assertEquals(-5.0, LinearEquation.solve(1, 5));
}
@Test
void testSolveWithZeroB() {
assertEquals(0.0, LinearEquation.solve(4, 0), 1e-9);
}
@Test
void testSolveWithNegativeA() {
assertEquals(3.0, LinearEquation.solve(-3, 9));
}
@Test
void testAllIllegalInput() {
assertAll(() -> assertThrows(IllegalArgumentException.class, () -> LinearEquation.solve(0, 5)), () -> assertThrows(IllegalArgumentException.class, () -> LinearEquation.solve(0, 0)), () -> assertThrows(IllegalArgumentException.class, () -> LinearEquation.solve(0, -3)));
}
}