|
1 | 1 | import unittest
|
2 | 2 |
|
3 |
| -from grains import ( |
4 |
| - on_square, |
5 |
| - total_after, |
6 |
| -) |
| 3 | +from grains import square, total |
7 | 4 |
|
8 | 5 |
|
9 | 6 | # Tests adapted from `problem-specifications//canonical-data.json` @ v1.2.0
|
10 | 7 |
|
11 | 8 | class GrainsTest(unittest.TestCase):
|
12 | 9 | def test_square_1(self):
|
13 |
| - self.assertEqual(on_square(1), 1) |
| 10 | + self.assertEqual(square(1), 1) |
14 | 11 |
|
15 | 12 | def test_square_2(self):
|
16 |
| - self.assertEqual(on_square(2), 2) |
| 13 | + self.assertEqual(square(2), 2) |
17 | 14 |
|
18 | 15 | def test_square_3(self):
|
19 |
| - self.assertEqual(on_square(3), 4) |
| 16 | + self.assertEqual(square(3), 4) |
20 | 17 |
|
21 | 18 | def test_square_4(self):
|
22 |
| - self.assertEqual(on_square(4), 8) |
| 19 | + self.assertEqual(square(4), 8) |
23 | 20 |
|
24 | 21 | def test_square_16(self):
|
25 |
| - self.assertEqual(on_square(16), 32768) |
| 22 | + self.assertEqual(square(16), 32768) |
26 | 23 |
|
27 | 24 | def test_square_32(self):
|
28 |
| - self.assertEqual(on_square(32), 2147483648) |
| 25 | + self.assertEqual(square(32), 2147483648) |
29 | 26 |
|
30 | 27 | def test_square_64(self):
|
31 |
| - self.assertEqual(on_square(64), 9223372036854775808) |
| 28 | + self.assertEqual(square(64), 9223372036854775808) |
32 | 29 |
|
33 | 30 | def test_square_0_raises_exception(self):
|
34 | 31 | with self.assertRaisesWithMessage(ValueError):
|
35 |
| - on_square(0) |
| 32 | + square(0) |
36 | 33 | with self.assertRaisesWithMessage(ValueError):
|
37 |
| - total_after(0) |
| 34 | + total(0) |
38 | 35 |
|
39 | 36 | def test_square_negative_raises_exception(self):
|
40 | 37 | with self.assertRaisesWithMessage(ValueError):
|
41 |
| - on_square(-1) |
| 38 | + square(-1) |
42 | 39 | with self.assertRaisesWithMessage(ValueError):
|
43 |
| - total_after(-1) |
| 40 | + total(-1) |
44 | 41 |
|
45 | 42 | def test_square_gt_64_raises_exception(self):
|
46 | 43 | with self.assertRaisesWithMessage(ValueError):
|
47 |
| - on_square(65) |
| 44 | + square(65) |
48 | 45 | with self.assertRaisesWithMessage(ValueError):
|
49 |
| - total_after(65) |
| 46 | + total(65) |
50 | 47 |
|
51 | 48 | def test_total(self):
|
52 |
| - self.assertEqual(total_after(64), 18446744073709551615) |
| 49 | + self.assertEqual(total(64), 18446744073709551615) |
53 | 50 |
|
54 | 51 | # Utility functions
|
55 | 52 | def setUp(self):
|
|
0 commit comments