|
5 | 5 | import static org.junit.jupiter.api.Assertions.*;
|
6 | 6 |
|
7 | 7 | public class LongDivisionTest {
|
8 |
| - |
| 8 | + |
| 9 | + // Requirement: Dividend (positive) is greater than divisor (positive), returns correct integer after division |
9 | 10 | @Test
|
10 | 11 | void testOne() {
|
11 | 12 | assertEquals(3, LongDivision.divide(10,3));
|
12 | 13 | }
|
13 |
| - |
14 |
| - @Test |
| 14 | + |
| 15 | + // Requirement: Dividend (positive) is greater than divisor (negative), returns correct integer after division |
| 16 | + @Test |
15 | 17 | void testTwo() {
|
16 | 18 | assertEquals(-2, LongDivision.divide(7,-3));
|
17 | 19 | }
|
18 | 20 |
|
19 |
| - |
20 |
| - @Test |
| 21 | + // Requirement: Dividend (positive) is greater than divisor (negative), returns correct integer after division |
| 22 | + // Basically the same as in the first test |
| 23 | + @Test |
21 | 24 | void testThree() {
|
22 | 25 | assertEquals(10, LongDivision.divide(105,10));
|
23 | 26 | }
|
| 27 | + |
| 28 | + // Requirement: Dividend (negative), divisor (positive), returns correct integer after division |
| 29 | + // Tests the case where the dividend is less than 0. |
| 30 | + @Test |
| 31 | + void testNegativeDividend() { |
| 32 | + assertEquals(-1, LongDivision.divide(-5,3)); |
| 33 | + } |
24 | 34 |
|
| 35 | + // Requirement: Dividend (positive), divisor (positive), returns correct integer after division |
| 36 | + // Tests the case where the dividend is less than the divisor. The test should return 0 in this case. |
| 37 | + @Test |
| 38 | + void testDividendLessThanDivisor() { |
| 39 | + assertEquals(0, LongDivision.divide(3,5)); |
| 40 | + } |
| 41 | + |
| 42 | + // Requirement: Dividend (neither), divisor (positive), returns correct integer after division |
| 43 | + // Tests the case where the dividend is 0. This should return a 0. |
| 44 | + @Test |
| 45 | + void testDividendIsZero() { |
| 46 | + assertEquals(0, LongDivision.divide(0,5)); |
| 47 | + } |
| 48 | + |
| 49 | + // Requirement: Dividend (positive), divisor (neither), returns correct integer after division |
| 50 | + // Tests the case where the divisor is 0. This should return a 0. |
| 51 | + @Test |
| 52 | + void testDivisionByZero() { |
| 53 | + assertEquals(0, LongDivision.divide(5,0)); |
| 54 | + } |
25 | 55 | }
|
0 commit comments