1- import org .junit .Assert ;
2- import org .junit .Before ;
3- import org .junit .Ignore ;
4- import org .junit .Test ;
5-
6- public class RunLengthEncodingTest {
7- private RunLengthEncoding runLengthEncoding ;
8-
9- @ Before
10- public void setUp () {
11- runLengthEncoding = new RunLengthEncoding ();
12- }
13-
14- @ Test
15- public void encodeEmpty () {
16- Assert .assertEquals ("" , runLengthEncoding .encode ("" ));
17- }
18-
19- @ Test
20- public void decodeEmpty () {
21- Assert .assertEquals ("" , runLengthEncoding .decode ("" ));
22- }
23-
24- @ Ignore ("Remove to run test" )
25- @ Test
26- public void encodeWithOnlySingleValues () {
27- Assert .assertEquals ("XYZ" , runLengthEncoding .encode ("XYZ" ));
28- }
29-
30- @ Ignore ("Remove to run test" )
31- @ Test
32- public void decodeWithOnlySingleValues () {
33- Assert .assertEquals ("XYZ" , runLengthEncoding .decode ("XYZ" ));
34- }
35-
36- @ Ignore ("Remove to run test" )
37- @ Test
38- public void encodeWithMixedValues () {
39- Assert .assertEquals ("12WB12W3B24WB" , runLengthEncoding .encode ("WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB" ));
40- }
41-
42- @ Ignore ("Remove to run test" )
43- @ Test
44- public void decodeWithMixedValues () {
45- Assert .assertEquals ("WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB" , runLengthEncoding .decode ("12WB12W3B24WB" ));
46- }
47-
48- @ Ignore ("Remove to run test" )
49- @ Test
50- public void encodeWithWhitespaceValues () {
51- Assert .assertEquals ("2 hs2q q2w2 " , runLengthEncoding .encode (" hsqq qww " ));
52- }
53-
54- @ Ignore ("Remove to run test" )
55- @ Test
56- public void decodeWithWhitespaceValues () {
57- Assert .assertEquals (" hsqq qww " , runLengthEncoding .decode ("2 hs2q q2w2 " ));
58- }
59-
60- @ Ignore ("Remove to run test" )
61- @ Test
62- public void encodeWithLowercaseValues () {
63- Assert .assertEquals ("2a3b4c" , runLengthEncoding .encode ("aabbbcccc" ));
64- }
65-
66- @ Ignore ("Remove to run test" )
67- @ Test
68- public void decodeWithLowercaseValues () {
69- Assert .assertEquals ("aabbbcccc" , runLengthEncoding .decode ("2a3b4c" ));
70- }
71-
72- @ Ignore ("Remove to run test" )
73- @ Test
74- public void encodeThenDecode () {
75- String inOut = "zzz ZZ zZ" ;
76- String encoded = runLengthEncoding .encode (inOut );
77- Assert .assertEquals (inOut , runLengthEncoding .decode (encoded ));
78- }
1+ import org .junit .Assert ;
2+ import org .junit .Before ;
3+ import org .junit .Ignore ;
4+ import org .junit .Test ;
5+
6+ public class RunLengthEncodingTest {
7+ private RunLengthEncoding runLengthEncoding ;
8+
9+ @ Before
10+ public void setUp () {
11+ runLengthEncoding = new RunLengthEncoding ();
12+ }
13+
14+ @ Test
15+ public void encodeEmpty () {
16+ Assert .assertEquals ("" , runLengthEncoding .encode ("" ));
17+ }
18+
19+ @ Ignore ("Remove to run test" )
20+ @ Test
21+ public void encodeWithOnlySingleValues () {
22+ Assert .assertEquals ("XYZ" , runLengthEncoding .encode ("XYZ" ));
23+ }
24+
25+ @ Ignore ("Remove to run test" )
26+ @ Test
27+ public void encodeWithNoSingleValues () {
28+ Assert .assertEquals ("2A3B4C" , runLengthEncoding .encode ("AABBBCCCC" ));
29+ }
30+
31+ @ Ignore ("Remove to run test" )
32+ @ Test
33+ public void encodeWithMixedValues () {
34+ Assert .assertEquals ("12WB12W3B24WB" , runLengthEncoding .encode ("WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB" ));
35+ }
36+
37+ @ Ignore ("Remove to run test" )
38+ @ Test
39+ public void encodeWithWhitespaceValues () {
40+ Assert .assertEquals ("2 hs2q q2w2 " , runLengthEncoding .encode (" hsqq qww " ));
41+ }
42+
43+ @ Ignore ("Remove to run test" )
44+ @ Test
45+ public void encodeWithLowercaseValues () {
46+ Assert .assertEquals ("2a3b4c" , runLengthEncoding .encode ("aabbbcccc" ));
47+ }
48+
49+ @ Ignore ("Remove to run test" )
50+ @ Test
51+ public void decodeEmpty () {
52+ Assert .assertEquals ("" , runLengthEncoding .decode ("" ));
53+ }
54+
55+ @ Ignore ("Remove to run test" )
56+ @ Test
57+ public void decodeWithOnlySingleValues () {
58+ Assert .assertEquals ("XYZ" , runLengthEncoding .decode ("XYZ" ));
59+ }
60+
61+ @ Ignore ("Remove to run test" )
62+ @ Test
63+ public void decodeWithNoSingleValues () {
64+ Assert .assertEquals ("AABBBCCCC" , runLengthEncoding .decode ("2A3B4C" ));
65+ }
66+
67+ @ Ignore ("Remove to run test" )
68+ @ Test
69+ public void decodeWithMixedValues () {
70+ Assert .assertEquals ("WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB" , runLengthEncoding .decode ("12WB12W3B24WB" ));
71+ }
72+
73+ @ Ignore ("Remove to run test" )
74+ @ Test
75+ public void decodeWithWhitespaceValues () {
76+ Assert .assertEquals (" hsqq qww " , runLengthEncoding .decode ("2 hs2q q2w2 " ));
77+ }
78+
79+ @ Ignore ("Remove to run test" )
80+ @ Test
81+ public void decodeWithLowercaseValues () {
82+ Assert .assertEquals ("aabbbcccc" , runLengthEncoding .decode ("2a3b4c" ));
83+ }
84+
85+ @ Ignore ("Remove to run test" )
86+ @ Test
87+ public void encodeThenDecode () {
88+ String inOut = "zzz ZZ zZ" ;
89+ String encoded = runLengthEncoding .encode (inOut );
90+ Assert .assertEquals (inOut , runLengthEncoding .decode (encoded ));
91+ }
7992}
0 commit comments