|
26 | 26 |
|
27 | 27 | import org.apache.commons.lang3.AbstractLangTest; |
28 | 28 | import org.junit.jupiter.api.Test; |
| 29 | +import org.junit.jupiter.params.ParameterizedTest; |
| 30 | +import org.junit.jupiter.params.provider.CsvSource; |
29 | 31 |
|
30 | 32 | /** |
31 | 33 | * Test cases for the {@link Fraction} class |
@@ -616,17 +618,29 @@ public void testHashCode() { |
616 | 618 | assertTrue(f1.hashCode() != f2.hashCode()); |
617 | 619 | f2 = Fraction.getFraction(6, 10); |
618 | 620 | assertTrue(f1.hashCode() != f2.hashCode()); |
619 | | - // Use cases from https://issues.apache.org/jira/browse/LANG-1764 |
620 | | - assertNotEquals(Fraction.getFraction(0, 37), Fraction.getFraction(-464320789, 46)); |
621 | | - assertNotEquals(Fraction.getFraction(0, 37), Fraction.getFraction(-464320788, 9)); |
622 | | - assertNotEquals(Fraction.getFraction(0, 37), Fraction.getFraction(1857283155, 38)); |
623 | | - assertNotEquals(Fraction.getFraction(0, 25185704), Fraction.getFraction(1161454280, 1050304)); |
624 | | - assertNotEquals(Fraction.getFraction(0, 38817068), Fraction.getFraction(1509581512, 18875972)); |
625 | | - assertNotEquals(Fraction.getFraction(0, 38817068), Fraction.getFraction(-2146369536, 2145078572)); |
626 | | - assertNotEquals(Fraction.getFraction(1400217380, 128), Fraction.getFraction(2092630052, 150535040)); |
627 | | - assertNotEquals(Fraction.getFraction(1400217380, 128), Fraction.getFraction(-580400986, 268435638)); |
628 | | - assertNotEquals(Fraction.getFraction(1400217380, 2147483592), Fraction.getFraction(-2147483648, 268435452)); |
629 | | - assertNotEquals(Fraction.getFraction(1756395909, 4194598), Fraction.getFraction(1174949894, 42860673)); |
| 621 | + } |
| 622 | + |
| 623 | + /** |
| 624 | + * Tests https://issues.apache.org/jira/browse/LANG-1764 |
| 625 | + */ |
| 626 | + @ParameterizedTest |
| 627 | + // @formatter:off |
| 628 | + @CsvSource({ |
| 629 | + "0, 37, -464320789, 46", |
| 630 | + "0, 37, -464320788, 9", |
| 631 | + "0, 37, 1857283155, 38", |
| 632 | + "0, 25185704, 1161454280, 1050304", |
| 633 | + "0, 38817068, 1509581512, 18875972", |
| 634 | + "0, 38817068, -2146369536, 2145078572", |
| 635 | + "1400217380, 128, 2092630052, 150535040", |
| 636 | + "1400217380, 128, -580400986, 268435638", |
| 637 | + "1400217380, 2147483592, -2147483648, 268435452", |
| 638 | + "1756395909, 4194598, 1174949894, 42860673" |
| 639 | + }) |
| 640 | + // @formatter:on |
| 641 | + public void testHashCodeNotEquals(int f1n, int f1d, int f2n, int f2d) { |
| 642 | + assertNotEquals(Fraction.getFraction(f1n, f1d), Fraction.getFraction(f2n, f2d)); |
| 643 | + assertNotEquals(Fraction.getFraction(f1n, f1d).hashCode(), Fraction.getFraction(f2n, f2d).hashCode()); |
630 | 644 | } |
631 | 645 |
|
632 | 646 | @Test |
|
0 commit comments