|
2 | 2 |
|
3 | 3 | import static org.junit.jupiter.api.Assertions.assertEquals; |
4 | 4 |
|
5 | | -import java.util.stream.Stream; |
| 5 | +import java.util.Arrays; |
| 6 | +import java.util.List; |
6 | 7 |
|
7 | 8 | import org.junit.jupiter.params.ParameterizedTest; |
8 | | -import org.junit.jupiter.params.provider.CsvSource; |
9 | 9 | import org.junit.jupiter.params.provider.MethodSource; |
10 | 10 |
|
11 | | -import es.codeurjc.test.complex.Complex; |
12 | | - |
13 | 11 | public class ComplexAbs2Test { |
14 | 12 |
|
15 | | - static class ComplexAndValue { |
16 | | - |
17 | | - public Complex complex; |
18 | | - public double value; |
19 | | - |
20 | | - public ComplexAndValue(Complex complex, double value) { |
21 | | - this.complex = complex; |
22 | | - this.value = value; |
23 | | - } |
24 | | - } |
25 | | - |
26 | 13 | @ParameterizedTest |
27 | 14 | @MethodSource("values") |
28 | | - public void absoluteTest(ComplexAndValue complexAndValue) { |
29 | | - |
30 | | - Complex complex = complexAndValue.complex; |
31 | | - double abs = complexAndValue.value; |
| 15 | + public void absoluteTest(Complex complex, double abs) { |
32 | 16 |
|
33 | 17 | assertEquals(complex.abs(), abs, 0.001); |
34 | 18 | } |
35 | 19 |
|
36 | | - public static Stream<ComplexAndValue> values() { |
37 | | - return Stream.of( |
38 | | - new ComplexAndValue(new Complex(0, 0), 0), |
39 | | - new ComplexAndValue(new Complex(1, 1), 1.41421), |
40 | | - new ComplexAndValue(new Complex(2, 2), 2.82843), |
41 | | - new ComplexAndValue(new Complex(5, 5), 7.07107), |
42 | | - new ComplexAndValue(new Complex(10, 10), 14.1421), |
43 | | - new ComplexAndValue(new Complex(10, 1), 10.0498), |
44 | | - new ComplexAndValue(new Complex(20, 2), 20.099) |
45 | | - ); |
| 20 | + public static List<Object[]> values() { |
| 21 | + |
| 22 | + Object[][] values = { |
| 23 | + { new Complex(0, 0), 0 }, |
| 24 | + { new Complex(1, 1), 1.41421 }, |
| 25 | + { new Complex(2, 2), 2.82843 }, |
| 26 | + { new Complex(5, 5), 7.07107 }, |
| 27 | + { new Complex(10, 10), 14.1421 }, |
| 28 | + { new Complex(10, 1), 10.0498 }, |
| 29 | + { new Complex(20, 2), 20.099 } |
| 30 | + }; |
| 31 | + |
| 32 | + return Arrays.asList(values); |
46 | 33 | } |
47 | 34 |
|
48 | 35 | } |
0 commit comments