1 package com.dvp.tutoriel.fibonacci;
2
3 import static junit.framework.Assert.assertEquals;
4
5 import org.junit.Before;
6 import org.junit.Test;
7
8
9
10
11
12
13
14 public class MaCalculetteTest {
15
16 private Calculette calculette;
17
18 @Before
19 public void doBefore() {
20 calculette = new MaCalculette();
21 }
22
23
24
25
26
27
28
29
30
31 @Test
32 public void testFibonacci_RG024_1() {
33
34 final Integer n = 1;
35 final long resultatAttendu = 1;
36
37
38 testFibonacci_RG024_x(n, resultatAttendu);
39 }
40
41
42
43
44
45
46
47
48
49 @Test
50 public void testFibonacci_RG024_2() {
51
52 final Integer n = 2;
53 final long resultatAttendu = 1;
54
55
56 testFibonacci_RG024_x(n, resultatAttendu);
57 }
58
59
60
61
62
63
64
65
66
67 @Test
68 public void testFibonacci_RG024_3_a() {
69
70 final Integer n = 3;
71 final long resultatAttendu = 2;
72
73
74 testFibonacci_RG024_x(n, resultatAttendu);
75 }
76
77
78
79
80
81
82
83
84
85 @Test
86 public void testFibonacci_RG024_3_b() {
87
88 final Integer n = 4;
89 final long resultatAttendu = 3;
90
91
92 testFibonacci_RG024_x(n, resultatAttendu);
93 }
94
95
96
97
98
99
100
101
102
103 @Test
104 public void testFibonacci_RG024_3_c() {
105
106 final Integer n = 5;
107 final long resultatAttendu = 5;
108
109
110 testFibonacci_RG024_x(n, resultatAttendu);
111 }
112
113
114
115
116
117
118
119
120
121 @Test
122 public void testFibonacci_RG024_3_d() {
123
124 final Integer n = 6;
125 final long resultatAttendu = 8;
126
127
128 testFibonacci_RG024_x(n, resultatAttendu);
129 }
130
131
132
133
134
135
136
137
138
139 @Test
140 public void testFibonacci_RG024_3_e() {
141
142 final Integer n = 7;
143 final long resultatAttendu = 13;
144
145
146 testFibonacci_RG024_x(n, resultatAttendu);
147 }
148
149
150
151
152
153
154
155
156
157 @Test
158 public void testFibonacci_RG024_3_f() {
159
160 final Integer n = 8;
161 final long resultatAttendu = 21;
162
163
164 testFibonacci_RG024_x(n, resultatAttendu);
165 }
166
167
168
169
170
171
172
173
174
175
176 @Test(expected = IllegalArgumentException.class)
177 public void testFibonacci_RG024_4_a() {
178
179 final Integer n = 0;
180
181
182 testFibonacci_RG024_x(n, null);
183 }
184
185
186
187
188
189
190
191
192
193
194 @Test(expected = IllegalArgumentException.class)
195 public void testFibonacci_RG024_4_b() {
196
197 final Integer n = -1;
198
199
200 testFibonacci_RG024_x(n, null);
201 }
202
203
204
205
206
207
208
209
210
211 @Test(timeout = 2000)
212 public void testFibonacci_RG024_5() {
213
214 final Integer n = 55;
215 final long resultatAttendu = 139583862445L;
216
217
218 testFibonacci_RG024_x(n, resultatAttendu);
219 }
220
221
222
223
224
225
226
227
228
229 @Test(timeout = 1000)
230 public void testFibonacci_RG024_6() {
231
232 final Integer n = 49;
233 final long resultatAttendu = 7778742049L;
234
235
236 testFibonacci_RG024_x(n, resultatAttendu);
237 }
238
239
240
241 private void testFibonacci_RG024_x(Integer n, Long resultatAttendu) {
242
243 final Long resultatCalcule = calculette.fibonacci(n);
244
245
246 assertEquals(resultatAttendu, resultatCalcule);
247 }
248
249 }