-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProjectTests.java
130 lines (111 loc) · 3.88 KB
/
ProjectTests.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
package test;
import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;
import app.*;
public class ProjectTests {
RLEconverter conv;
/** Fixture initialization (common initialization
* for all tests). **/
@Before public void setUp() {
conv = new RLEconverter();
}
//compress tests
@Test
public void compressLineTest1() {
char[] fileChars = {'0','1'};
String line = "000000";
String correctRes = "6";
String actualRes = conv.compressLine(line, fileChars);
assertEquals("Test 1: Test the compressLine method.", correctRes, actualRes);
}
@Test
public void compressLineTest2() {
char[] fileChars = {'0','1'};
String line = "11111111";
String correctRes = "0,8";
String actualRes = conv.compressLine(line, fileChars);
assertEquals("Test 2: Test the compressLine method.", correctRes, actualRes);
}
@Test
public void compressLineTest3() {
char[] fileChars = {'0','1'};
String line = "1111111111000";
String correctRes = "0,10,3";
String actualRes = conv.compressLine(line, fileChars);
assertEquals("Test 3: Test the compressLine method.", correctRes, actualRes);
}
@Test
public void compressLineTest4() {
char[] fileChars = {'1','0'};
String line = "1111111111000";
String correctRes = "10,3";
String actualRes = conv.compressLine(line, fileChars);
assertEquals("Test 4: Test the compressLine method.", correctRes, actualRes);
}
@Test
public void compressLineTest5() {
char[] fileChars = {'0','1'};
String line = "11111111110001";
String correctRes = "0,10,3,1";
String actualRes = conv.compressLine(line, fileChars);
assertEquals("Test 5: Test the compressLine method.", correctRes, actualRes);
}
@Test
public void compressLineTest6() {
char[] fileChars = {'_','$'};
String line = "___________$$$$$$$$$$$$$$$______________";
String correctRes = "11,15,14";
String actualRes = conv.compressLine(line, fileChars);
assertEquals("Test 6: Test the compressLine method.", correctRes, actualRes);
}
// decompress tests
@Test
public void decompressLineTest1() {
char[] fileChars = {'0','1'};
String line = "8";
String correctRes = "00000000";
String actualRes = conv.decompressLine(line, fileChars);
assertEquals("Test 9: Test the decompressLine method.", correctRes, actualRes);
}
@Test
public void decompressLineTest2() {
char[] fileChars = {'0','1'};
String line = "0,10";
String correctRes = "1111111111";
String actualRes = conv.decompressLine(line, fileChars);
assertEquals("Test 10: Test the decompressLine method.", correctRes, actualRes);
}
@Test
public void decompressLineTest3() {
char[] fileChars = {'0','1'};
String line = "0,9,3";
String correctRes = "111111111000";
String actualRes = conv.decompressLine(line, fileChars);
assertEquals("Test 11: Test the decompressLine method.", correctRes, actualRes);
}
@Test
public void decompressLineTest4() {
char[] fileChars = {'1','0'};
String line = "9,4";
String correctRes = "1111111110000";
String actualRes = conv.decompressLine(line, fileChars);
assertEquals("Test 12: Test the decompressLine method.", correctRes, actualRes);
}
@Test
public void decompressLineTest5() {
char[] fileChars = {'0','1'};
String line = "0,11,3,1";
String correctRes = "111111111110001";
String actualRes = conv.decompressLine(line, fileChars);
assertEquals("Test 13: Test the decompressLine method.", correctRes, actualRes);
}
@Test
public void decompressLineTest6() {
char[] fileChars = {'_','$'};
String line = "9,14,14";
String correctRes = "_________$$$$$$$$$$$$$$______________";
String actualRes = conv.decompressLine(line, fileChars);
assertEquals("Test 14: Test the decompressLine method.", correctRes, actualRes);
}
}