-
Notifications
You must be signed in to change notification settings - Fork 0
/
HighScoresTest.java
46 lines (36 loc) · 1.13 KB
/
HighScoresTest.java
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
import static org.junit.Assert.*;
import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import org.junit.Test;
public class HighScoresTest {
@Test
public void testRead() throws IOException {
HighScores h;
ArrayList<Score> hs_actual = new ArrayList<Score> ();
try {
h = HighScores.make("files/read.txt");
hs_actual = h.getScores();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
ArrayList<Score> hs_expected = new ArrayList<Score>();
hs_expected.add(new Score("linda", 5));
hs_expected.add(new Score("monica", 4));
hs_expected.add(new Score("james", 3));
hs_expected.add(new Score("diana", 2));
hs_expected.add(new Score("gillian", 1));
Collections.sort(hs_expected, Collections.reverseOrder());
for (int i = 0; i < 5; i++) {
Score c = hs_actual.get(i);
String p = c.getUser() + ((Integer) c.getScore()).toString();
System.out.println(p);
}
for (int i = 0; i < 5; i++) {
Score c = hs_expected.get(i);
String p = c.getUser() + ((Integer) c.getScore()).toString();
System.out.println(p);
}
assertEquals("scores", hs_expected, hs_actual);
}
}