Skip to content

Commit 98271a4

Browse files
authored
Sync two-bucket (#929)
[no important files changed]
1 parent 3f58069 commit 98271a4

File tree

2 files changed

+39
-29
lines changed

2 files changed

+39
-29
lines changed

exercises/practice/two-bucket/.meta/tests.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ description = "Measure one step using bucket one of size 1 and bucket two of siz
2727
[eb329c63-5540-4735-b30b-97f7f4df0f84]
2828
description = "Measure using bucket one of size 2 and bucket two of size 3 - start with bucket one and end with bucket two"
2929

30+
[58d70152-bf2b-46bb-ad54-be58ebe94c03]
31+
description = "Measure using bucket one much bigger than bucket two"
32+
33+
[9dbe6499-caa5-4a58-b5ce-c988d71b8981]
34+
description = "Measure using bucket one much smaller than bucket two"
35+
3036
[449be72d-b10a-4f4b-a959-ca741e333b72]
3137
description = "Not possible to reach the goal"
3238

exercises/practice/two-bucket/TwoBucketTest.php

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,12 @@
77

88
class TwoBucketTest extends TestCase
99
{
10-
private TwoBucket $twoBucket;
11-
1210
public static function setUpBeforeClass(): void
1311
{
1412
require_once 'TwoBucket.php';
1513
}
1614

17-
/**
18-
* uuid: a6f2b4ba-065f-4dca-b6f0-e3eee51cb661
19-
*/
15+
/** uuid: a6f2b4ba-065f-4dca-b6f0-e3eee51cb661 */
2016
#[TestDox('Measure using bucket one of size 3 and bucket two of size 5 - start with bucket one')]
2117
public function testMeasureUsingBucketOneOfSize3AndBucketTwoOfSize5StartWithBucketOne(): void
2218
{
@@ -28,9 +24,7 @@ public function testMeasureUsingBucketOneOfSize3AndBucketTwoOfSize5StartWithBuck
2824
$this->assertEquals(5, $solution->litersLeftInOtherBucket);
2925
}
3026

31-
/**
32-
* uuid: 6c4ea451-9678-4926-b9b3-68364e066d40
33-
*/
27+
/** uuid: 6c4ea451-9678-4926-b9b3-68364e066d40 */
3428
#[TestDox('Measure using bucket one of size 3 and bucket two of size 5 - start with bucket two')]
3529
public function testMeasureUsingBucketOneOfSize3AndBucketTwoOfSize5StartWithBucketTwo(): void
3630
{
@@ -42,9 +36,7 @@ public function testMeasureUsingBucketOneOfSize3AndBucketTwoOfSize5StartWithBuck
4236
$this->assertEquals(3, $solution->litersLeftInOtherBucket);
4337
}
4438

45-
/**
46-
* uuid: 3389f45e-6a56-46d5-9607-75aa930502ff
47-
*/
39+
/** uuid: 3389f45e-6a56-46d5-9607-75aa930502ff */
4840
#[TestDox('Measure using bucket one of size 7 and bucket two of size 11 - start with bucket one')]
4941
public function testMeasureUsingBucketOneOfSize7AndBucketTwoOfSize11StartWithBucketOne(): void
5042
{
@@ -56,9 +48,7 @@ public function testMeasureUsingBucketOneOfSize7AndBucketTwoOfSize11StartWithBuc
5648
$this->assertEquals(11, $solution->litersLeftInOtherBucket);
5749
}
5850

59-
/**
60-
* uuid: fe0ff9a0-3ea5-4bf7-b17d-6d4243961aa1
61-
*/
51+
/** uuid: fe0ff9a0-3ea5-4bf7-b17d-6d4243961aa1 */
6252
#[TestDox('Measure using bucket one of size 7 and bucket two of size 11 - start with bucket two')]
6353
public function testMeasureUsingBucketOneOfSize7AndBucketTwoOfSize11StartWithBucketTwo(): void
6454
{
@@ -70,9 +60,7 @@ public function testMeasureUsingBucketOneOfSize7AndBucketTwoOfSize11StartWithBuc
7060
$this->assertEquals(7, $solution->litersLeftInOtherBucket);
7161
}
7262

73-
/**
74-
* uuid: 0ee1f57e-da84-44f7-ac91-38b878691602
75-
*/
63+
/** uuid: 0ee1f57e-da84-44f7-ac91-38b878691602 */
7664
#[TestDox('Measure one step using bucket one of size 1 and bucket two of size 3 - start with bucket two')]
7765
public function testMeasureOneStepUsingBucketOneOfSize1AndBucketTwoOfSize3StartWithBucketTwo(): void
7866
{
@@ -84,9 +72,7 @@ public function testMeasureOneStepUsingBucketOneOfSize1AndBucketTwoOfSize3StartW
8472
$this->assertEquals(0, $solution->litersLeftInOtherBucket);
8573
}
8674

87-
/**
88-
* uuid: eb329c63-5540-4735-b30b-97f7f4df0f84
89-
*/
75+
/** uuid: eb329c63-5540-4735-b30b-97f7f4df0f84 */
9076
#[TestDox('Measure using bucket one of size 2 and bucket two of size 3 - start with bucket one and end with bucket two')]
9177
public function testMeasureUsingBucketOneOfSize2AndBucketTwoOfSize3StartWithBucketOneAndEndWithBucketTwo(): void
9278
{
@@ -98,9 +84,31 @@ public function testMeasureUsingBucketOneOfSize2AndBucketTwoOfSize3StartWithBuck
9884
$this->assertEquals(2, $solution->litersLeftInOtherBucket);
9985
}
10086

101-
/**
102-
* uuid: 449be72d-b10a-4f4b-a959-ca741e333b72
103-
*/
87+
/** uuid: 58d70152-bf2b-46bb-ad54-be58ebe94c03 */
88+
#[TestDox('Measure using bucket one much bigger than bucket two')]
89+
public function testMeasureUsingBucketOneMuchBiggerThanBucketTwo(): void
90+
{
91+
$subject = new TwoBucket();
92+
$solution = $subject->solve(5, 1, 2, 'one');
93+
94+
$this->assertEquals(6, $solution->numberOfActions);
95+
$this->assertEquals('one', $solution->nameOfBucketWithDesiredLiters);
96+
$this->assertEquals(1, $solution->litersLeftInOtherBucket);
97+
}
98+
99+
/** uuid: 9dbe6499-caa5-4a58-b5ce-c988d71b8981 */
100+
#[TestDox('Measure using bucket one much smaller than bucket two')]
101+
public function testMeasureUsingBucketOneMuchSmallerThanBucketTwo(): void
102+
{
103+
$subject = new TwoBucket();
104+
$solution = $subject->solve(3, 15, 9, 'one');
105+
106+
$this->assertEquals(6, $solution->numberOfActions);
107+
$this->assertEquals('two', $solution->nameOfBucketWithDesiredLiters);
108+
$this->assertEquals(0, $solution->litersLeftInOtherBucket);
109+
}
110+
111+
/** uuid: 449be72d-b10a-4f4b-a959-ca741e333b72 */
104112
#[TestDox('Not possible to reach the goal')]
105113
public function testReachabilityNotPossibleToReachGoalStartWithBucketOne(): void
106114
{
@@ -110,9 +118,7 @@ public function testReachabilityNotPossibleToReachGoalStartWithBucketOne(): void
110118
$subject->solve(6, 15, 5, 'one');
111119
}
112120

113-
/**
114-
* uuid: aac38b7a-77f4-4d62-9b91-8846d533b054
115-
*/
121+
/** uuid: aac38b7a-77f4-4d62-9b91-8846d533b054 */
116122
#[TestDox('With the same buckets but a different goal, then it is possible')]
117123
public function testWithSameBucketsButDifferentGoalItIsPossible(): void
118124
{
@@ -124,9 +130,7 @@ public function testWithSameBucketsButDifferentGoalItIsPossible(): void
124130
$this->assertEquals(0, $solution->litersLeftInOtherBucket);
125131
}
126132

127-
/**
128-
* uuid: 74633132-0ccf-49de-8450-af4ab2e3b299
129-
*/
133+
/** uuid: 74633132-0ccf-49de-8450-af4ab2e3b299 */
130134
#[TestDox('Goal larger than both buckets is impossible')]
131135
public function testGoalLargerThanBothBucketsIsImpossible(): void
132136
{

0 commit comments

Comments
 (0)