-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathNumberSampleTests.java
More file actions
29 lines (24 loc) · 1.28 KB
/
NumberSampleTests.java
File metadata and controls
29 lines (24 loc) · 1.28 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
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import ru.msu.vmk.NumberSample;
import java.math.BigDecimal;
import java.util.stream.Stream;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
public class NumberSampleTests {
@ParameterizedTest
@MethodSource("provideParameters")
public void splitTest(BigDecimal amount, int n, BigDecimal[] expected){
var splitted = NumberSample.split(amount, n);
assertArrayEquals(expected, splitted);
}
private static Stream<Arguments> provideParameters() {
return Stream.of(
Arguments.of(new BigDecimal("0.1"), 2, new BigDecimal[]{new BigDecimal("0.05"), new BigDecimal("0.05")}),
Arguments.of(new BigDecimal("1.0"), 2, new BigDecimal[]{new BigDecimal("0.5"), new BigDecimal("0.5")}),
Arguments.of(new BigDecimal("2.0"), 2, new BigDecimal[]{new BigDecimal("1.0"), new BigDecimal("1.0")}),
Arguments.of(new BigDecimal("5.0"), 2, new BigDecimal[]{new BigDecimal("2.5"), new BigDecimal("2.5")}),
Arguments.of(new BigDecimal("10.0"), 2, new BigDecimal[]{new BigDecimal("5.0"), new BigDecimal("5.0")})
);
}
}