Skip to content

Commit d43353d

Browse files
committed
Use Object[] instead of ComplexAndValue
1 parent 5130e82 commit d43353d

1 file changed

Lines changed: 16 additions & 29 deletions

File tree

tema1_2_ejer3/src/test/java/es/codeurjc/test/complex/ComplexAbs2Test.java

Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,34 @@
22

33
import static org.junit.jupiter.api.Assertions.assertEquals;
44

5-
import java.util.stream.Stream;
5+
import java.util.Arrays;
6+
import java.util.List;
67

78
import org.junit.jupiter.params.ParameterizedTest;
8-
import org.junit.jupiter.params.provider.CsvSource;
99
import org.junit.jupiter.params.provider.MethodSource;
1010

11-
import es.codeurjc.test.complex.Complex;
12-
1311
public class ComplexAbs2Test {
1412

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-
2613
@ParameterizedTest
2714
@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) {
3216

3317
assertEquals(complex.abs(), abs, 0.001);
3418
}
3519

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);
4633
}
4734

4835
}

0 commit comments

Comments
 (0)