Skip to content

Commit ca1518f

Browse files
committed
refactor(puzzles, arrays): candy, additional tests
1 parent ec7bf4d commit ca1518f

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

puzzles/arrays/candy/test_candy.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
import unittest
2-
3-
from . import candy
2+
from typing import List
3+
from parameterized import parameterized
4+
from puzzles.arrays.candy import candy
45

56

67
class CandyTestCase(unittest.TestCase):
7-
def test_1(self):
8-
ratings = [1, 0, 2]
9-
expected = 5
10-
actual = candy(ratings)
11-
self.assertEqual(expected, actual)
12-
13-
def test_2(self):
14-
ratings = [1, 2, 2]
15-
expected = 4
8+
@parameterized.expand([
9+
([1], 1),
10+
([1, 0, 2], 5),
11+
([1, 2, 2], 4),
12+
([1,3,4,5,2], 11),
13+
([1,3,4,5,2], 11),
14+
([1,2,3,4,5], 15),
15+
([5,4,3,2,1], 15),
16+
([5,5,5,5,5,5,5,5], 8),
17+
])
18+
def test_candy(self, ratings: List[int], expected: int):
1619
actual = candy(ratings)
1720
self.assertEqual(expected, actual)
1821

0 commit comments

Comments
 (0)