-
-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathtwo_bucket.vader
53 lines (45 loc) · 2.76 KB
/
two_bucket.vader
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
Execute (Measure using bucket one of size 3 and bucket two of size 5 - start with bucket one):
let g:input = {"bucketOne": 3, "bucketTwo": 5, "goal": 1, "startBucket": "one"}
let g:expected = {"moves": 4, "goalBucket": "one", "otherBucket": 5}
let g:game = TwoBucket(g:input)
AssertEqual g:expected, g:game.Measure()
Execute (Measure using bucket one of size 3 and bucket two of size 5 - start with bucket two):
let g:input = { "bucketOne": 3, "bucketTwo": 5, "goal": 1, "startBucket": "two" }
let g:expected = { "moves": 8, "goalBucket": "two", "otherBucket": 3 }
let g:game = TwoBucket(g:input)
AssertEqual g:expected, g:game.Measure()
Execute (Measure using bucket one of size 7 and bucket two of size 11 - start with bucket one):
let g:input = { "bucketOne": 7, "bucketTwo": 11, "goal": 2, "startBucket": "one" }
let g:expected = { "moves": 14, "goalBucket": "one", "otherBucket": 11 }
let g:game = TwoBucket(g:input)
AssertEqual g:expected, g:game.Measure()
Execute (Measure using bucket one of size 7 and bucket two of size 11 - start with bucket two):
let g:input = { "bucketOne": 7, "bucketTwo": 11, "goal": 2, "startBucket": "two" }
let g:expected = { "moves": 18, "goalBucket": "two", "otherBucket": 7 }
let g:game = TwoBucket(g:input)
AssertEqual g:expected, g:game.Measure()
Execute (Measure one step using bucket one of size 1 and bucket two of size 3 - start with bucket two):
let g:input = { "bucketOne": 1, "bucketTwo": 3, "goal": 3, "startBucket": "two" }
let g:expected = { "moves": 1, "goalBucket": "two", "otherBucket": 0 }
let g:game = TwoBucket(g:input)
AssertEqual g:expected, g:game.Measure()
Execute (Measure using bucket one of size 2 and bucket two of size 3 - start with bucket one and end with bucket two):
let g:input = { "bucketOne": 2, "bucketTwo": 3, "goal": 3, "startBucket": "one" }
let g:expected = { "moves": 2, "goalBucket": "two", "otherBucket": 2 }
let g:game = TwoBucket(g:input)
AssertEqual g:expected, g:game.Measure()
Execute (Not possible to reach the goal):
let g:input = { "bucketOne": 6, "bucketTwo": 15, "goal": 5, "startBucket": "one" }
let g:expected = "impossible"
AssertThrows call TwoBucket(g:input)
AssertEqual g:expected, g:vader_exception
Execute (With the same buckets but a different goal, then it is possible):
let g:input = { "bucketOne": 6, "bucketTwo": 15, "goal": 9, "startBucket": "one" }
let g:expected = { "moves": 10, "goalBucket": "two", "otherBucket": 0 }
let g:game = TwoBucket(g:input)
AssertEqual g:expected, g:game.Measure()
Execute (Goal larger than both buckets is impossible):
let g:input = { "bucketOne": 5, "bucketTwo": 7, "goal": 8, "startBucket": "one" }
let g:expected = "impossible"
AssertThrows call TwoBucket(g:input)
AssertEqual g:expected, g:vader_exception