forked from TheAlgorithms/Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComplexNumberMultiplyTest.java
More file actions
34 lines (26 loc) · 902 Bytes
/
ComplexNumberMultiplyTest.java
File metadata and controls
34 lines (26 loc) · 902 Bytes
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
package com.thealgorithms.maths;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import org.junit.jupiter.api.Test;
public class ComplexNumberMultiplyTest {
@Test
void testExample() {
assertEquals("0+2i", ComplexNumberMultiply.multiply("1+1i", "1+1i"));
}
@Test
void testNegative() {
assertEquals("0+-2i", ComplexNumberMultiply.multiply("1+-1i", "1+-1i"));
}
@Test
void testZero() {
assertEquals("0+0i", ComplexNumberMultiply.multiply("0+0i", "5+3i"));
}
@Test
void testInvalidFormat() {
assertThrows(IllegalArgumentException.class, () -> ComplexNumberMultiply.multiply("1+1", "1+1i"));
}
@Test
void testNullInput() {
assertThrows(IllegalArgumentException.class, () -> ComplexNumberMultiply.multiply(null, "1+1i"));
}
}