Skip to content
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

grains: Update tests to match canonical-data #1058

Merged
merged 4 commits into from
Nov 5, 2017
Merged
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
12 changes: 5 additions & 7 deletions exercises/grains/grains_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,29 @@
)


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

class GrainsTest(unittest.TestCase):
def test_square_1(self):
self.assertEqual(on_square(1), 1)
self.assertEqual(total_after(1), 1)

def test_square_2(self):
self.assertEqual(on_square(2), 2)
self.assertEqual(total_after(2), 3)

def test_square_3(self):
self.assertEqual(on_square(3), 4)
self.assertEqual(total_after(3), 7)

def test_square_4(self):
self.assertEqual(on_square(4), 8)
self.assertEqual(total_after(4), 15)

def test_square_16(self):
self.assertEqual(on_square(16), 32768)
self.assertEqual(total_after(16), 65535)

def test_square_32(self):
self.assertEqual(on_square(32), 2147483648)
self.assertEqual(total_after(32), 4294967295)

def test_square_64(self):
self.assertEqual(on_square(64), 9223372036854775808)
self.assertEqual(total_after(64), 18446744073709551615)

def test_square_0_raises_exception(self):
with self.assertRaises(ValueError):
Expand All @@ -53,6 +48,9 @@ def test_square_gt_64_raises_exception(self):
with self.assertRaises(ValueError):
total_after(65)

def test_total(self):
self.assertEqual(total_after(64), 18446744073709551615)


if __name__ == '__main__':
unittest.main()