-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathCountTextTest.java
More file actions
41 lines (33 loc) · 1.18 KB
/
Copy pathCountTextTest.java
File metadata and controls
41 lines (33 loc) · 1.18 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
import model.CountText;
import org.junit.Test;
import static org.junit.Assert.*;
public class CountTextTest {
private String sentence = "Java Application";
private char[] char4count = {'a', 'I', 'c'};
private String sentence2 = "Hello WorLd";
private char[] char4count2 = {'H', 'e', 'l', 'o', 'W'};
@Test
public void checkResult() {
int[] expectResult = {4, 2, 1};
int[] result = CountText.countCharInText(sentence, char4count);
assertArrayEquals(expectResult, result);
}
@Test
public void checkLength() {
int expectResult = 3;
int result = CountText.countCharInText(sentence, char4count).length;
assertEquals(expectResult, result);
}
@Test
public void checkResult2() {
int[] expectResult = {1, 1, 3, 2, 1};
int[] result = CountText.countCharInText(sentence2, char4count2);
assertArrayEquals(expectResult, result);
}
@Test
public void checkLength2() {
int expectResult = 5;
int result = CountText.countCharInText(sentence2, char4count2).length;
assertEquals(expectResult, result);
}
}