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