-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringsTest.java
More file actions
64 lines (53 loc) · 2.3 KB
/
StringsTest.java
File metadata and controls
64 lines (53 loc) · 2.3 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package net.theevilreaper.aves.util;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import java.util.stream.Stream;
import static org.junit.jupiter.api.Assertions.*;
class StringsTest {
private static final Stream<Arguments> TIME_ARGUMENTS = Stream.of(
Arguments.of("00:00", Strings.getTimeString(TimeFormat.MM_SS, 0)),
Arguments.of("01:00", Strings.getTimeString(TimeFormat.MM_SS, 60)),
Arguments.of("01:00:00", Strings.getTimeString(TimeFormat.HH_MM_SS, 3600)),
Arguments.of("00:59:59", Strings.getTimeString(TimeFormat.HH_MM_SS, 3599)),
Arguments.of("01:01:39", Strings.getTimeString(TimeFormat.HH_MM_SS, 3699)),
Arguments.of("00:00:00", Strings.getTimeString(TimeFormat.HH_MM_SS, -23))
);
private static Stream<Arguments> getArguments() {
return TIME_ARGUMENTS;
}
private static Stream<Arguments> getLineArguments() {
return LINE_ARGUMENTS;
}
private static final Stream<Arguments> LINE_ARGUMENTS = Stream.of(
Arguments.of(assertThrows(
IllegalArgumentException.class,
() -> Strings.centerText("", 10)).getMessage(),
"The text can not be empty"
),
Arguments.of(
assertThrows(
IllegalArgumentException.class,
() -> Strings.centerText("Hallo", 2)).getMessage(),
"The length of the line must be greater than the text length"
),
Arguments.of(Strings.centerText("Hallo", 8), " Hallo "),
Arguments.of(Strings.centerText("Hallo", 10), " Hallo ")
);
@ParameterizedTest
@MethodSource("getArguments")
void testGetTimeString(String expected, String value) {
assertEquals(expected, value);
}
@ParameterizedTest
@MethodSource("getLineArguments")
void testCenterString(String expected, String value) {
assertEquals(expected, value);
}
@Test
void testFalseCenterText() {
var centeredText = Strings.centerText("Hallo", 9);
assertNotEquals(" Hallo ", centeredText);
}
}