|
| 1 | +package com.thealgorithms.greedyalgorithms; |
| 2 | + |
| 3 | +import static org.junit.jupiter.api.Assertions.assertEquals; |
| 4 | + |
| 5 | +import java.util.List; |
| 6 | +import org.junit.jupiter.api.Test; |
| 7 | +public class DigitSeparationTest { |
| 8 | + |
| 9 | + @Test |
| 10 | + public void testDigitSeparationReverseOrderSingleDigit() { |
| 11 | + DigitSeparation digitSeparation = new DigitSeparation(); |
| 12 | + List<Long> result = digitSeparation.digitSeparationReverseOrder(5); |
| 13 | + assertEquals(List.of(5L), result); |
| 14 | + } |
| 15 | + |
| 16 | + @Test |
| 17 | + public void testDigitSeparationReverseOrderMultipleDigits() { |
| 18 | + DigitSeparation digitSeparation = new DigitSeparation(); |
| 19 | + List<Long> result = digitSeparation.digitSeparationReverseOrder(123); |
| 20 | + assertEquals(List.of(3L, 2L, 1L), result); |
| 21 | + } |
| 22 | + |
| 23 | + @Test |
| 24 | + public void testDigitSeparationReverseOrderLargeNumber() { |
| 25 | + DigitSeparation digitSeparation = new DigitSeparation(); |
| 26 | + List<Long> result = digitSeparation.digitSeparationReverseOrder(123456789); |
| 27 | + assertEquals(List.of(9L, 8L, 7L, 6L, 5L, 4L, 3L, 2L, 1L), result); |
| 28 | + } |
| 29 | + |
| 30 | + @Test |
| 31 | + public void testDigitSeparationReverseOrderZero() { |
| 32 | + DigitSeparation digitSeparation = new DigitSeparation(); |
| 33 | + List<Long> result = digitSeparation.digitSeparationReverseOrder(0); |
| 34 | + assertEquals(List.of(0L), result); |
| 35 | + } |
| 36 | + |
| 37 | + @Test |
| 38 | + public void testDigitSeparationReverseOrderNegativeNumbers() { |
| 39 | + DigitSeparation digitSeparation = new DigitSeparation(); |
| 40 | + List<Long> result = digitSeparation.digitSeparationReverseOrder(-123); |
| 41 | + assertEquals(List.of(3L, 2L, 1L), result); |
| 42 | + } |
| 43 | + |
| 44 | + @Test |
| 45 | + public void testDigitSeparationForwardOrderSingleDigit() { |
| 46 | + DigitSeparation digitSeparation = new DigitSeparation(); |
| 47 | + List<Long> result = digitSeparation.digitSeparationForwardOrder(5); |
| 48 | + assertEquals(List.of(5L), result); |
| 49 | + } |
| 50 | + |
| 51 | + @Test |
| 52 | + public void testDigitSeparationForwardOrderMultipleDigits() { |
| 53 | + DigitSeparation digitSeparation = new DigitSeparation(); |
| 54 | + List<Long> result = digitSeparation.digitSeparationForwardOrder(123); |
| 55 | + assertEquals(List.of(1L, 2L, 3L), result); |
| 56 | + } |
| 57 | + |
| 58 | + @Test |
| 59 | + public void testDigitSeparationForwardOrderLargeNumber() { |
| 60 | + DigitSeparation digitSeparation = new DigitSeparation(); |
| 61 | + List<Long> result = digitSeparation.digitSeparationForwardOrder(123456789); |
| 62 | + assertEquals(List.of(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L), result); |
| 63 | + } |
| 64 | + |
| 65 | + @Test |
| 66 | + public void testDigitSeparationForwardOrderZero() { |
| 67 | + DigitSeparation digitSeparation = new DigitSeparation(); |
| 68 | + List<Long> result = digitSeparation.digitSeparationForwardOrder(0); |
| 69 | + assertEquals(List.of(0L), result); |
| 70 | + } |
| 71 | + |
| 72 | + @Test |
| 73 | + public void testDigitSeparationForwardOrderNegativeNumber() { |
| 74 | + DigitSeparation digitSeparation = new DigitSeparation(); |
| 75 | + List<Long> result = digitSeparation.digitSeparationForwardOrder(-123); |
| 76 | + assertEquals(List.of(1L, 2L, 3L), result); |
| 77 | + } |
| 78 | +} |
0 commit comments