Skip to content

two-bucket: update tests to v1.4.0 #1334

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Feb 20, 2018
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 3 additions & 4 deletions exercises/two-bucket/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
'''


def two_bucket(bucket_one_cap, bucket_two_cap, desired_liters, first):
sizes = [bucket_one_cap, bucket_two_cap]
goal = desired_liters
goalIndex = 0 if first == 'one' else 1
def measure(bucket_one, bucket_two, goal, start_bucket):
sizes = [bucket_one, bucket_two]
goalIndex = 0 if start_bucket == 'one' else 1

def empty(buckets, i):
return [0, buckets[1]] if i == 0 else [buckets[0], 0]
Expand Down
2 changes: 1 addition & 1 deletion exercises/two-bucket/two_bucket.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
def two_bucket(bucket_one_cap, bucket_two_cap, desired_liters, first):
def measure(bucket_one, bucket_two, goal, start_bucket):
pass
21 changes: 8 additions & 13 deletions exercises/two-bucket/two_bucket_test.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,28 @@
'''
All test cases adapted from
exercism/problem-specifications/exercises/two-bucket/canonical-data.json
'''

import unittest

from two_bucket import two_bucket
from two_bucket import measure


# Tests adapted from `problem-specifications//canonical-data.json` @ v1.2.0
# Tests adapted from `problem-specifications//canonical-data.json` @ v1.4.0

class TwoBucketTest(unittest.TestCase):
def test_bucket_one_size_3_bucket_two_size_5_start_with_bucket_one(self):
self.assertEqual(two_bucket(3, 5, 1, "one"), (4, "one", 5))
self.assertEqual(measure(3, 5, 1, "one"), (4, "one", 5))

def test_bucket_one_size_3_bucket_two_size_5_start_with_bucket_two(self):
self.assertEqual(two_bucket(3, 5, 1, "two"), (8, "two", 3))
self.assertEqual(measure(3, 5, 1, "two"), (8, "two", 3))

def test_bucket_one_size_7_bucket_two_size_11_start_with_bucket_one(self):
self.assertEqual(two_bucket(7, 11, 2, "one"), (14, "one", 11))
self.assertEqual(measure(7, 11, 2, "one"), (14, "one", 11))

def test_bucket_one_size_7_bucket_two_size_11_start_with_bucket_two(self):
self.assertEqual(two_bucket(7, 11, 2, "two"), (18, "two", 7))
self.assertEqual(measure(7, 11, 2, "two"), (18, "two", 7))

def test_bucket_one_size_1_bucket_two_size_3_start_with_bucket_two(self):
self.assertEqual(two_bucket(1, 3, 3, "two"), (1, "two", 0))
self.assertEqual(measure(1, 3, 3, "two"), (1, "two", 0))

def test_bucket_one_size_2_bucket_two_size_3_start_with_bucket_one(self):
self.assertEqual(two_bucket(2, 3, 3, "one"), (2, "two", 2))
self.assertEqual(measure(2, 3, 3, "one"), (2, "two", 2))


if __name__ == '__main__':
Expand Down