|
3 | 3 |
|
4 | 4 | import static org.assertj.core.api.Assertions.assertThat; |
5 | 5 |
|
| 6 | +import java.util.Collections; |
| 7 | + |
6 | 8 | public class TwoBucketTest { |
7 | 9 |
|
8 | 10 | @Test |
@@ -75,4 +77,52 @@ public void testBucketOneSizeTwoBucketTwoSizeThreeStartWithOne() { |
75 | 77 | assertThat(twoBucket.getOtherBucket()).isEqualTo(2); |
76 | 78 |
|
77 | 79 | } |
| 80 | + |
| 81 | + @Disabled("Remove to run test") |
| 82 | + @Test |
| 83 | + public void testReachingGoalIsImpossible() { |
| 84 | + |
| 85 | + TwoBucket twoBucket = new TwoBucket(6, 15, 5, "one"); |
| 86 | + |
| 87 | + assertThatExceptionOfType(IllegalArgumentException.class) |
| 88 | + .isThrownBy(() -> twoBucket.getTotalMoves())) |
| 89 | + .withMessage("impossible"); |
| 90 | + assertThatExceptionOfType(IllegalArgumentException.class) |
| 91 | + .isThrownBy(() -> twoBucket.getFinalBucket())) |
| 92 | + .withMessage("impossible"); |
| 93 | + assertThatExceptionOfType(IllegalArgumentException.class) |
| 94 | + .isThrownBy(() -> twoBucket.getOtherBucket())) |
| 95 | + .withMessage("impossible"); |
| 96 | + |
| 97 | + } |
| 98 | + |
| 99 | + @Disabled("Remove to run test") |
| 100 | + @Test |
| 101 | + public void testBucketOneSizeSixBucketTwoSizeFifteenStartWithOne() { |
| 102 | + |
| 103 | + TwoBucket twoBucket = new TwoBucket(6, 15, 9, "one"); |
| 104 | + |
| 105 | + assertThat(twoBucket.getTotalMoves()).isEqualTo(10); |
| 106 | + assertThat(twoBucket.getFinalBucket()).isEqualTo("two"); |
| 107 | + assertThat(twoBucket.getOtherBucket()).isEqualTo(0); |
| 108 | + |
| 109 | + } |
| 110 | + |
| 111 | + @Disabled("Remove to run test") |
| 112 | + @Test |
| 113 | + public void testGoalLargerThanBothBucketsIsImpossible() { |
| 114 | + |
| 115 | + TwoBucket twoBucket = new TwoBucket(5, 7, 8, "one"); |
| 116 | + |
| 117 | + assertThatExceptionOfType(IllegalArgumentException.class) |
| 118 | + .isThrownBy(() -> twoBucket.getTotalMoves())) |
| 119 | + .withMessage("impossible"); |
| 120 | + assertThatExceptionOfType(IllegalArgumentException.class) |
| 121 | + .isThrownBy(() -> twoBucket.getFinalBucket())) |
| 122 | + .withMessage("impossible"); |
| 123 | + assertThatExceptionOfType(IllegalArgumentException.class) |
| 124 | + .isThrownBy(() -> twoBucket.getOtherBucket())) |
| 125 | + .withMessage("impossible"); |
| 126 | + |
| 127 | + } |
78 | 128 | } |
0 commit comments