|
@@ -5,66 +5,66 @@ import org.junit.After;
|
5
|
5
|
import org.junit.Before;
|
6
|
6
|
import org.junit.Test;
|
7
|
7
|
|
8
|
|
-public class BonusTest
|
|
8
|
+public class LoopFunTest
|
9
|
9
|
{
|
10
|
|
- private Bonus bonus;
|
11
|
|
-
|
|
10
|
+ private LoopFun loop;
|
|
11
|
+
|
12
|
12
|
@Before
|
13
|
13
|
public void setUp(){
|
14
|
|
- bonus = new Bonus();
|
|
14
|
+ loop = new LoopFun();
|
15
|
15
|
}
|
16
|
|
-
|
|
16
|
+
|
17
|
17
|
@Test
|
18
|
18
|
public void testFactorialBase(){
|
19
|
19
|
//Given
|
20
|
20
|
int number = 1;
|
21
|
21
|
int expected = 1;
|
22
|
|
-
|
|
22
|
+
|
23
|
23
|
//When
|
24
|
|
- int actual = bonus.factorial(number);
|
25
|
|
-
|
|
24
|
+ int actual = loop.factorial(number);
|
|
25
|
+
|
26
|
26
|
//Then
|
27
|
27
|
assertEquals(expected, actual);
|
28
|
|
-
|
|
28
|
+
|
29
|
29
|
}
|
30
|
|
-
|
|
30
|
+
|
31
|
31
|
@Test
|
32
|
32
|
public void testFactorialOfSmallNumber(){
|
33
|
33
|
//Given
|
34
|
34
|
int number = 3;
|
35
|
35
|
int expected = 6;
|
36
|
|
-
|
|
36
|
+
|
37
|
37
|
//When
|
38
|
|
- int actual = bonus.factorial(number);
|
39
|
|
-
|
|
38
|
+ int actual = loop.factorial(number);
|
|
39
|
+
|
40
|
40
|
//Then
|
41
|
41
|
assertEquals(expected, actual);
|
42
|
|
-
|
|
42
|
+
|
43
|
43
|
}
|
44
|
|
-
|
|
44
|
+
|
45
|
45
|
@Test
|
46
|
46
|
public void testFactorialOfBigNumber(){
|
47
|
47
|
//Given
|
48
|
48
|
int number = 6;
|
49
|
49
|
int expected = 720;
|
50
|
|
-
|
|
50
|
+
|
51
|
51
|
//When
|
52
|
|
- int actual = bonus.factorial(number);
|
53
|
|
-
|
|
52
|
+ int actual = loop.factorial(number);
|
|
53
|
+
|
54
|
54
|
//Then
|
55
|
55
|
assertEquals(expected, actual);
|
56
|
|
-
|
|
56
|
+
|
57
|
57
|
}
|
58
|
|
-
|
|
58
|
+
|
59
|
59
|
@Test
|
60
|
60
|
public void testAcronymBasic() {
|
61
|
61
|
//Given
|
62
|
62
|
String phrase = "Portable Network Graphics";
|
63
|
63
|
String expected = "PNG";
|
64
|
|
-
|
|
64
|
+
|
65
|
65
|
//When
|
66
|
|
- String actual = bonus.acronym(phrase);
|
67
|
|
-
|
|
66
|
+ String actual = loop.acronym(phrase);
|
|
67
|
+
|
68
|
68
|
//Then
|
69
|
69
|
assertEquals(expected, actual);
|
70
|
70
|
}
|
|
@@ -74,10 +74,10 @@ public class BonusTest
|
74
|
74
|
//Given
|
75
|
75
|
String phrase = "Ruby on Rails";
|
76
|
76
|
String expected = "ROR";
|
77
|
|
-
|
|
77
|
+
|
78
|
78
|
//When
|
79
|
|
- String actual = bonus.acronym(phrase);
|
80
|
|
-
|
|
79
|
+ String actual = loop.acronym(phrase);
|
|
80
|
+
|
81
|
81
|
//Then
|
82
|
82
|
assertEquals(expected, actual);
|
83
|
83
|
}
|
|
@@ -87,10 +87,10 @@ public class BonusTest
|
87
|
87
|
//Given
|
88
|
88
|
String phrase = "First In, First Out";
|
89
|
89
|
String expected = "FIFO";
|
90
|
|
-
|
|
90
|
+
|
91
|
91
|
//When
|
92
|
|
- String actual = bonus.acronym(phrase);
|
93
|
|
-
|
|
92
|
+ String actual = loop.acronym(phrase);
|
|
93
|
+
|
94
|
94
|
//Then
|
95
|
95
|
assertEquals(expected, actual);
|
96
|
96
|
}
|
|
@@ -100,43 +100,43 @@ public class BonusTest
|
100
|
100
|
//Given
|
101
|
101
|
String phrase = "GNU Image Manipulation Program";
|
102
|
102
|
String expected = "GIMP";
|
103
|
|
-
|
|
103
|
+
|
104
|
104
|
//When
|
105
|
|
- String actual = bonus.acronym(phrase);
|
106
|
|
-
|
|
105
|
+ String actual = loop.acronym(phrase);
|
|
106
|
+
|
107
|
107
|
//Then
|
108
|
108
|
assertEquals(expected, actual);
|
109
|
109
|
}
|
110
|
|
-
|
111
|
|
-
|
112
|
|
-
|
113
|
|
-
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
114
|
114
|
@Test
|
115
|
115
|
public void testEncryptWithTheFirstAlphabet(){
|
116
|
116
|
//Given
|
117
|
117
|
String word = "apple";
|
118
|
118
|
String expected = "dssoh";
|
119
|
|
-
|
|
119
|
+
|
120
|
120
|
//When
|
121
|
|
- String actual = bonus.encrypt(word);
|
122
|
|
-
|
|
121
|
+ String actual = loop.encrypt(word);
|
|
122
|
+
|
123
|
123
|
//Then
|
124
|
124
|
assertEquals(expected, actual);
|
125
|
125
|
}
|
126
|
|
-
|
|
126
|
+
|
127
|
127
|
@Test
|
128
|
128
|
public void testEncryptWithTheLastLetters(){
|
129
|
129
|
//Given
|
130
|
130
|
String word = "wxyz";
|
131
|
131
|
String expected = "zabc";
|
132
|
|
-
|
|
132
|
+
|
133
|
133
|
//When
|
134
|
|
- String actual = bonus.encrypt(word);
|
135
|
|
-
|
|
134
|
+ String actual = loop.encrypt(word);
|
|
135
|
+
|
136
|
136
|
//Then
|
137
|
137
|
assertEquals(expected, actual);
|
138
|
138
|
}
|
139
|
|
-
|
140
|
|
-
|
|
139
|
+
|
|
140
|
+
|
141
|
141
|
|
142
|
142
|
}
|