11import org .junit .jupiter .api .Disabled ;
2+ import org .junit .jupiter .api .DisplayName ;
23import org .junit .jupiter .api .Test ;
34
45import static org .assertj .core .api .Assertions .assertThat ;
@@ -17,6 +18,7 @@ private void assertDoublesEqual(double x, double y) {
1718 // Tests
1819
1920 @ Test
21+ @ DisplayName ("Add two positive rational numbers" )
2022 public void testAddTwoPositiveRationalNumbers () {
2123 Rational expected = new Rational (7 , 6 );
2224 Rational actual = new Rational (1 , 2 ).add (new Rational (2 , 3 ));
@@ -25,6 +27,7 @@ public void testAddTwoPositiveRationalNumbers() {
2527
2628 @ Disabled ("Remove to run test" )
2729 @ Test
30+ @ DisplayName ("Add a positive rational number and a negative rational number" )
2831 public void testAddAPositiveRationalNumberAndANegativeRationalNumber () {
2932 Rational expected = new Rational (-1 , 6 );
3033 Rational actual = new Rational (1 , 2 ).add (new Rational (-2 , 3 ));
@@ -33,6 +36,7 @@ public void testAddAPositiveRationalNumberAndANegativeRationalNumber() {
3336
3437 @ Disabled ("Remove to run test" )
3538 @ Test
39+ @ DisplayName ("Add two negative rational numbers" )
3640 public void testAddTwoNegativeRationalNumbers () {
3741 Rational expected = new Rational (-7 , 6 );
3842 Rational actual = new Rational (-1 , 2 ).add (new Rational (-2 , 3 ));
@@ -41,6 +45,7 @@ public void testAddTwoNegativeRationalNumbers() {
4145
4246 @ Disabled ("Remove to run test" )
4347 @ Test
48+ @ DisplayName ("Add a rational number to its additive inverse" )
4449 public void testAddARationalNumberToItsAdditiveInverse () {
4550 Rational expected = new Rational (0 , 1 );
4651 Rational actual = new Rational (1 , 2 ).add (new Rational (-1 , 2 ));
@@ -49,6 +54,7 @@ public void testAddARationalNumberToItsAdditiveInverse() {
4954
5055 @ Disabled ("Remove to run test" )
5156 @ Test
57+ @ DisplayName ("Subtract two positive rational numbers" )
5258 public void testSubtractTwoPositiveRationalNumbers () {
5359 Rational expected = new Rational (-1 , 6 );
5460 Rational actual = new Rational (1 , 2 ).subtract (new Rational (2 , 3 ));
@@ -57,6 +63,7 @@ public void testSubtractTwoPositiveRationalNumbers() {
5763
5864 @ Disabled ("Remove to run test" )
5965 @ Test
66+ @ DisplayName ("Subtract a positive rational number and a negative rational number" )
6067 public void testSubtractAPositiveRationalNumberAndANegativeRationalNumber () {
6168 Rational expected = new Rational (7 , 6 );
6269 Rational actual = new Rational (1 , 2 ).subtract (new Rational (-2 , 3 ));
@@ -65,6 +72,7 @@ public void testSubtractAPositiveRationalNumberAndANegativeRationalNumber() {
6572
6673 @ Disabled ("Remove to run test" )
6774 @ Test
75+ @ DisplayName ("Subtract two negative rational numbers" )
6876 public void testSubtractTwoNegativeRationalNumbers () {
6977 Rational expected = new Rational (1 , 6 );
7078 Rational actual = new Rational (-1 , 2 ).subtract (new Rational (-2 , 3 ));
@@ -73,6 +81,7 @@ public void testSubtractTwoNegativeRationalNumbers() {
7381
7482 @ Disabled ("Remove to run test" )
7583 @ Test
84+ @ DisplayName ("Subtract a rational number from itself" )
7685 public void testSubtractARationalNumberFromItself () {
7786 Rational expected = new Rational (0 , 1 );
7887 Rational actual = new Rational (1 , 2 ).subtract (new Rational (1 , 2 ));
@@ -81,6 +90,7 @@ public void testSubtractARationalNumberFromItself() {
8190
8291 @ Disabled ("Remove to run test" )
8392 @ Test
93+ @ DisplayName ("Multiply two positive rational numbers" )
8494 public void testMultiplyTwoPositiveRationalNumbers () {
8595 Rational expected = new Rational (1 , 3 );
8696 Rational actual = new Rational (1 , 2 ).multiply (new Rational (2 , 3 ));
@@ -89,6 +99,7 @@ public void testMultiplyTwoPositiveRationalNumbers() {
8999
90100 @ Disabled ("Remove to run test" )
91101 @ Test
102+ @ DisplayName ("Multiply a negative rational number by a positive rational number" )
92103 public void testMultiplyANegativeRationalNumberByAPositiveRationalNumber () {
93104 Rational expected = new Rational (-1 , 3 );
94105 Rational actual = new Rational (-1 , 2 ).multiply (new Rational (2 , 3 ));
@@ -97,6 +108,7 @@ public void testMultiplyANegativeRationalNumberByAPositiveRationalNumber() {
97108
98109 @ Disabled ("Remove to run test" )
99110 @ Test
111+ @ DisplayName ("Multiply two negative rational numbers" )
100112 public void testMultiplyTwoNegativeRationalNumbers () {
101113 Rational expected = new Rational (1 , 3 );
102114 Rational actual = new Rational (-1 , 2 ).multiply (new Rational (-2 , 3 ));
@@ -105,6 +117,7 @@ public void testMultiplyTwoNegativeRationalNumbers() {
105117
106118 @ Disabled ("Remove to run test" )
107119 @ Test
120+ @ DisplayName ("Multiply a rational number by its reciprocal" )
108121 public void testMultiplyARationalNumberByItsReciprocal () {
109122 Rational expected = new Rational (1 , 1 );
110123 Rational actual = new Rational (1 , 2 ).multiply (new Rational (2 , 1 ));
@@ -113,6 +126,7 @@ public void testMultiplyARationalNumberByItsReciprocal() {
113126
114127 @ Disabled ("Remove to run test" )
115128 @ Test
129+ @ DisplayName ("Multiply a rational number by 1" )
116130 public void testMultiplyARationalNumberByOne () {
117131 Rational expected = new Rational (1 , 2 );
118132 Rational actual = new Rational (1 , 2 ).multiply (new Rational (1 , 1 ));
@@ -121,6 +135,7 @@ public void testMultiplyARationalNumberByOne() {
121135
122136 @ Disabled ("Remove to run test" )
123137 @ Test
138+ @ DisplayName ("Multiply a rational number by 0" )
124139 public void testMultiplyARationalNumberByZero () {
125140 Rational expected = new Rational (0 , 1 );
126141 Rational actual = new Rational (1 , 2 ).multiply (new Rational (0 , 1 ));
@@ -129,6 +144,7 @@ public void testMultiplyARationalNumberByZero() {
129144
130145 @ Disabled ("Remove to run test" )
131146 @ Test
147+ @ DisplayName ("Divide two positive rational numbers" )
132148 public void testDivideTwoPositiveRationalNumbers () {
133149 Rational expected = new Rational (3 , 4 );
134150 Rational actual = new Rational (1 , 2 ).divide (new Rational (2 , 3 ));
@@ -137,6 +153,7 @@ public void testDivideTwoPositiveRationalNumbers() {
137153
138154 @ Disabled ("Remove to run test" )
139155 @ Test
156+ @ DisplayName ("Divide a positive rational number by a negative rational number" )
140157 public void testDivideAPositiveRationalNumberByANegativeRationalNumber () {
141158 Rational expected = new Rational (-3 , 4 );
142159 Rational actual = new Rational (1 , 2 ).divide (new Rational (-2 , 3 ));
@@ -145,6 +162,7 @@ public void testDivideAPositiveRationalNumberByANegativeRationalNumber() {
145162
146163 @ Disabled ("Remove to run test" )
147164 @ Test
165+ @ DisplayName ("Divide two negative rational numbers" )
148166 public void testDivideTwoNegativeRationalNumbers () {
149167 Rational expected = new Rational (3 , 4 );
150168 Rational actual = new Rational (-1 , 2 ).divide (new Rational (-2 , 3 ));
@@ -153,6 +171,7 @@ public void testDivideTwoNegativeRationalNumbers() {
153171
154172 @ Disabled ("Remove to run test" )
155173 @ Test
174+ @ DisplayName ("Divide a rational number by 1" )
156175 public void testDivideARationalNumberByOne () {
157176 Rational expected = new Rational (1 , 2 );
158177 Rational actual = new Rational (1 , 2 ).divide (new Rational (1 , 1 ));
@@ -161,6 +180,7 @@ public void testDivideARationalNumberByOne() {
161180
162181 @ Disabled ("Remove to run test" )
163182 @ Test
183+ @ DisplayName ("Absolute value of a positive rational number" )
164184 public void testAbsoluteValueOfAPositiveRationalNumber () {
165185 Rational expected = new Rational (1 , 2 );
166186 Rational actual = new Rational (1 , 2 ).abs ();
@@ -169,6 +189,7 @@ public void testAbsoluteValueOfAPositiveRationalNumber() {
169189
170190 @ Disabled ("Remove to run test" )
171191 @ Test
192+ @ DisplayName ("Absolute value of a positive rational number with negative numerator and denominator" )
172193 public void testAbsoluteValueOfAPositiveRationalNumberWithNegativeNumeratorAndDenominator () {
173194 Rational expected = new Rational (1 , 2 );
174195 Rational actual = new Rational (-1 , -2 ).abs ();
@@ -177,6 +198,7 @@ public void testAbsoluteValueOfAPositiveRationalNumberWithNegativeNumeratorAndDe
177198
178199 @ Disabled ("Remove to run test" )
179200 @ Test
201+ @ DisplayName ("Absolute value of a negative rational number" )
180202 public void testAbsoluteValueOfANegativeRationalNumber () {
181203 Rational expected = new Rational (1 , 2 );
182204 Rational actual = new Rational (-1 , 2 ).abs ();
@@ -185,6 +207,7 @@ public void testAbsoluteValueOfANegativeRationalNumber() {
185207
186208 @ Disabled ("Remove to run test" )
187209 @ Test
210+ @ DisplayName ("\" Absolute value of a negative rational number with negative denominator" )
188211 public void testAbsoluteValueOfANegativeRationalNumberWithNegativeDenominator () {
189212 Rational expected = new Rational (1 , 2 );
190213 Rational actual = new Rational (1 , -2 ).abs ();
@@ -193,6 +216,7 @@ public void testAbsoluteValueOfANegativeRationalNumberWithNegativeDenominator()
193216
194217 @ Disabled ("Remove to run test" )
195218 @ Test
219+ @ DisplayName ("Absolute value of zero" )
196220 public void testAbsoluteValueOfZero () {
197221 Rational expected = new Rational (0 , 1 );
198222 Rational actual = new Rational (0 , 1 ).abs ();
@@ -201,6 +225,7 @@ public void testAbsoluteValueOfZero() {
201225
202226 @ Disabled ("Remove to run test" )
203227 @ Test
228+ @ DisplayName ("Absolute value of a rational number is reduced to lowest terms" )
204229 public void testAbsoluteValueOfARationalNumberIsReducedToLowestTerms () {
205230 Rational expected = new Rational (1 , 2 );
206231 Rational actual = new Rational (2 , 4 ).abs ();
@@ -209,6 +234,7 @@ public void testAbsoluteValueOfARationalNumberIsReducedToLowestTerms() {
209234
210235 @ Disabled ("Remove to run test" )
211236 @ Test
237+ @ DisplayName ("Raise a positive rational number to a positive integer power" )
212238 public void testRaiseAPositiveRationalNumberToAPositiveIntegerPower () {
213239 Rational expected = new Rational (1 , 8 );
214240 Rational actual = new Rational (1 , 2 ).pow (3 );
@@ -217,6 +243,7 @@ public void testRaiseAPositiveRationalNumberToAPositiveIntegerPower() {
217243
218244 @ Disabled ("Remove to run test" )
219245 @ Test
246+ @ DisplayName ("Raise a negative rational number to a positive integer power" )
220247 public void testRaiseANegativeRationalNumberToAPositiveIntegerPower () {
221248 Rational expected = new Rational (-1 , 8 );
222249 Rational actual = new Rational (-1 , 2 ).pow (3 );
@@ -225,6 +252,7 @@ public void testRaiseANegativeRationalNumberToAPositiveIntegerPower() {
225252
226253 @ Disabled ("Remove to run test" )
227254 @ Test
255+ @ DisplayName ("Raise a positive rational number to a negative integer power" )
228256 public void testRaiseAPositiveRationalNumberToANegativeIntegerPower () {
229257 Rational expected = new Rational (25 , 9 );
230258 Rational actual = new Rational (3 , 5 ).pow (-2 );
@@ -233,6 +261,7 @@ public void testRaiseAPositiveRationalNumberToANegativeIntegerPower() {
233261
234262 @ Disabled ("Remove to run test" )
235263 @ Test
264+ @ DisplayName ("\" Raise a negative rational number to an even negative integer power" )
236265 public void testRaiseANegativeRationalNumberToAnEvenNegativeIntegerPower () {
237266 Rational expected = new Rational (25 , 9 );
238267 Rational actual = new Rational (-3 , 5 ).pow (-2 );
@@ -241,6 +270,7 @@ public void testRaiseANegativeRationalNumberToAnEvenNegativeIntegerPower() {
241270
242271 @ Disabled ("Remove to run test" )
243272 @ Test
273+ @ DisplayName ("Raise a negative rational number to an odd negative integer power" )
244274 public void testRaiseANegativeRationalNumberToAnOddNegativeIntegerPower () {
245275 Rational expected = new Rational (-125 , 27 );
246276 Rational actual = new Rational (-3 , 5 ).pow (-3 );
@@ -249,6 +279,7 @@ public void testRaiseANegativeRationalNumberToAnOddNegativeIntegerPower() {
249279
250280 @ Disabled ("Remove to run test" )
251281 @ Test
282+ @ DisplayName ("Raise zero to an integer power" )
252283 public void testRaiseZeroToAnIntegerPower () {
253284 Rational expected = new Rational (0 , 1 );
254285 Rational actual = new Rational (0 , 1 ).pow (5 );
@@ -257,6 +288,7 @@ public void testRaiseZeroToAnIntegerPower() {
257288
258289 @ Disabled ("Remove to run test" )
259290 @ Test
291+ @ DisplayName ("Raise one to an integer power" )
260292 public void testRaiseOneToAnIntegerPower () {
261293 Rational expected = new Rational (1 , 1 );
262294 Rational actual = new Rational (1 , 1 ).pow (4 );
@@ -265,6 +297,7 @@ public void testRaiseOneToAnIntegerPower() {
265297
266298 @ Disabled ("Remove to run test" )
267299 @ Test
300+ @ DisplayName ("Raise a positive rational number to the power of zero" )
268301 public void testRaiseAPositiveRationalNumberToThePowerOfZero () {
269302 Rational expected = new Rational (1 , 1 );
270303 Rational actual = new Rational (-1 , 2 ).pow (0 );
@@ -273,6 +306,7 @@ public void testRaiseAPositiveRationalNumberToThePowerOfZero() {
273306
274307 @ Disabled ("Remove to run test" )
275308 @ Test
309+ @ DisplayName ("Raise a real number to a positive rational number" )
276310 public void testRaiseARealNumberToAPositiveRationalNumber () {
277311 double expected = 16.0 ;
278312 double actual = new Rational (4 , 3 ).exp (8.0 );
@@ -281,6 +315,7 @@ public void testRaiseARealNumberToAPositiveRationalNumber() {
281315
282316 @ Disabled ("Remove to run test" )
283317 @ Test
318+ @ DisplayName ("Raise a real number to a negative rational number" )
284319 public void testRaiseARealNumberToANegativeRationalNumber () {
285320 double expected = 1.0 / 3 ;
286321 double actual = new Rational (-1 , 2 ).exp (9 );
@@ -289,6 +324,7 @@ public void testRaiseARealNumberToANegativeRationalNumber() {
289324
290325 @ Disabled ("Remove to run test" )
291326 @ Test
327+ @ DisplayName ("Reduce a positive rational number to lowest terms" )
292328 public void testReduceAPositiveRationalNumberToLowestTerms () {
293329 Rational expected = new Rational (1 , 2 );
294330 Rational actual = new Rational (2 , 4 );
@@ -297,6 +333,7 @@ public void testReduceAPositiveRationalNumberToLowestTerms() {
297333
298334 @ Disabled ("Remove to run test" )
299335 @ Test
336+ @ DisplayName ("Reduce places the minus sign on the numerator" )
300337 public void testReducePlacesTheMinusSignOnTheNumerator () {
301338 Rational expected = new Rational (-3 , 4 );
302339 Rational actual = new Rational (3 , -4 );
@@ -305,6 +342,7 @@ public void testReducePlacesTheMinusSignOnTheNumerator() {
305342
306343 @ Disabled ("Remove to run test" )
307344 @ Test
345+ @ DisplayName ("Reduce a negative rational number to lowest terms" )
308346 public void testReduceANegativeRationalNumberToLowestTerms () {
309347 Rational expected = new Rational (-2 , 3 );
310348 Rational actual = new Rational (-4 , 6 );
@@ -313,6 +351,7 @@ public void testReduceANegativeRationalNumberToLowestTerms() {
313351
314352 @ Disabled ("Remove to run test" )
315353 @ Test
354+ @ DisplayName ("Reduce a rational number with a negative denominator to lowest terms" )
316355 public void testReduceARationalNumberWithANegativeDenominatorToLowestTerms () {
317356 Rational expected = new Rational (-1 , 3 );
318357 Rational actual = new Rational (3 , -9 );
@@ -321,6 +360,7 @@ public void testReduceARationalNumberWithANegativeDenominatorToLowestTerms() {
321360
322361 @ Disabled ("Remove to run test" )
323362 @ Test
363+ @ DisplayName ("Reduce zero to lowest terms" )
324364 public void testReduceZeroToLowestTerms () {
325365 Rational expected = new Rational (0 , 1 );
326366 Rational actual = new Rational (0 , 6 );
@@ -329,6 +369,7 @@ public void testReduceZeroToLowestTerms() {
329369
330370 @ Disabled ("Remove to run test" )
331371 @ Test
372+ @ DisplayName ("Reduce an integer to lowest terms" )
332373 public void testReduceAnIntegerToLowestTerms () {
333374 Rational expected = new Rational (-2 , 1 );
334375 Rational actual = new Rational (-14 , 7 );
@@ -337,6 +378,7 @@ public void testReduceAnIntegerToLowestTerms() {
337378
338379 @ Disabled ("Remove to run test" )
339380 @ Test
381+ @ DisplayName ("Reduce one to lowest terms" )
340382 public void testReduceOneToLowestTerms () {
341383 Rational expected = new Rational (1 , 1 );
342384 Rational actual = new Rational (13 , 13 );
0 commit comments