Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion exercises/practice/two-bucket/.meta/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"muzimuzhi",
"sjwarner-bp",
"SleeplessByte",
"sshine"
"sshine",
"Xinri"
],
"files": {
"solution": [
Expand Down
6 changes: 6 additions & 0 deletions exercises/practice/two-bucket/.meta/tests.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ description = "Measure one step using bucket one of size 1 and bucket two of siz
[eb329c63-5540-4735-b30b-97f7f4df0f84]
description = "Measure using bucket one of size 2 and bucket two of size 3 - start with bucket one and end with bucket two"

[58d70152-bf2b-46bb-ad54-be58ebe94c03]
description = "Measure using bucket one much bigger than bucket two"

[9dbe6499-caa5-4a58-b5ce-c988d71b8981]
description = "Measure using bucket one much smaller than bucket two"

[449be72d-b10a-4f4b-a959-ca741e333b72]
description = "Not possible to reach the goal"

Expand Down
42 changes: 40 additions & 2 deletions exercises/practice/two-bucket/src/test/java/TwoBucketTest.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;
Expand All @@ -7,6 +8,7 @@
public class TwoBucketTest {

@Test
@DisplayName("Measure using bucket one of size 3 and bucket two of size 5 - start with bucket one")
public void testBucketOneSizeThreeBucketTwoSizeFiveStartWithOne() {

Result bucketResult = new TwoBucket(3, 5, 1, "one").getResult();
Expand All @@ -19,6 +21,7 @@ public void testBucketOneSizeThreeBucketTwoSizeFiveStartWithOne() {

@Disabled("Remove to run test")
@Test
@DisplayName("Measure using bucket one of size 3 and bucket two of size 5 - start with bucket two")
public void testBucketOneSizeThreeBucketTwoSizeFiveStartWithTwo() {

Result bucketResult = new TwoBucket(3, 5, 1, "two").getResult();
Expand All @@ -31,6 +34,7 @@ public void testBucketOneSizeThreeBucketTwoSizeFiveStartWithTwo() {

@Disabled("Remove to run test")
@Test
@DisplayName("Measure using bucket one of size 7 and bucket two of size 11 - start with bucket one")
public void testBucketOneSizeSevenBucketTwoSizeElevenStartWithOne() {

Result bucketResult = new TwoBucket(7, 11, 2, "one").getResult();
Expand All @@ -43,6 +47,7 @@ public void testBucketOneSizeSevenBucketTwoSizeElevenStartWithOne() {

@Disabled("Remove to run test")
@Test
@DisplayName("Measure using bucket one of size 7 and bucket two of size 11 - start with bucket two")
public void testBucketOneSizeSevenBucketTwoSizeElevenStartWithTwo() {

Result bucketResult = new TwoBucket(7, 11, 2, "two").getResult();
Expand All @@ -55,6 +60,7 @@ public void testBucketOneSizeSevenBucketTwoSizeElevenStartWithTwo() {

@Disabled("Remove to run test")
@Test
@DisplayName("Measure one step using bucket one of size 1 and bucket two of size 3 - start with bucket two")
public void testBucketOneSizeOneBucketTwoSizeThreeStartWithTwo() {

Result bucketResult = new TwoBucket(1, 3, 3, "two").getResult();
Expand All @@ -67,6 +73,9 @@ public void testBucketOneSizeOneBucketTwoSizeThreeStartWithTwo() {

@Disabled("Remove to run test")
@Test
@DisplayName(
"Measure using bucket one of size 2 and bucket two of size 3 - " +
"start with bucket one and end with bucket two")
Comment thread
xinri marked this conversation as resolved.
Outdated
public void testBucketOneSizeTwoBucketTwoSizeThreeStartWithOne() {

Result bucketResult = new TwoBucket(2, 3, 3, "one").getResult();
Expand All @@ -79,15 +88,43 @@ public void testBucketOneSizeTwoBucketTwoSizeThreeStartWithOne() {

@Disabled("Remove to run test")
@Test
@DisplayName("Measure using bucket one much bigger than bucket two")
public void testBucketOneMuchBiggerThanBucketTwo() {

Result bucketResult = new TwoBucket(5, 1, 2, "one").getResult();

assertThat(bucketResult.getTotalMoves()).isEqualTo(6);
assertThat(bucketResult.getFinalBucket()).isEqualTo("one");
assertThat(bucketResult.getOtherBucket()).isEqualTo(1);

}

@Disabled("Remove to run test")
@Test
@DisplayName("Measure using bucket one much smaller than bucket two")
public void testBucketOneMuchSmallerThanBucketTwo() {

Result bucketResult = new TwoBucket(3, 15, 9, "one").getResult();

assertThat(bucketResult.getTotalMoves()).isEqualTo(6);
assertThat(bucketResult.getFinalBucket()).isEqualTo("two");
assertThat(bucketResult.getOtherBucket()).isEqualTo(0);

}

@Disabled("Remove to run test")
@Test
@DisplayName("Not possible to reach the goal")
public void testReachingGoalIsImpossible() {

assertThatExceptionOfType(UnreachableGoalException.class)
.isThrownBy(() -> new TwoBucket(6, 15, 5, "one").getResult());

}

@Disabled("Remove to run test")
@Test
@DisplayName("With the same buckets but a different goal, then it is possible")
public void testBucketOneSizeSixBucketTwoSizeFifteenStartWithOne() {

Result bucketResult = new TwoBucket(6, 15, 9, "one").getResult();
Expand All @@ -96,10 +133,11 @@ public void testBucketOneSizeSixBucketTwoSizeFifteenStartWithOne() {
assertThat(bucketResult.getFinalBucket()).isEqualTo("two");
assertThat(bucketResult.getOtherBucket()).isEqualTo(0);

}
}

@Disabled("Remove to run test")
@Test
@DisplayName("Goal larger than both buckets is impossible")
public void testGoalLargerThanBothBucketsIsImpossible() {

assertThatExceptionOfType(UnreachableGoalException.class)
Expand Down