Skip to content

Commit

Permalink
utility/resizeToLength: Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
m-laniakea committed Nov 18, 2019
1 parent f5c9470 commit 2ba3a79
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/test_utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,34 @@ def testGetByteCount(self):
with self.assertRaises(AssertionError):
getByteCount(-1)

def testResizeToLength(self):
self.assertEqual(
resizeToLength([], 1),
[0]
)

self.assertEqual(
resizeToLength(['a'], 0),
[]
)

self.assertEqual(
resizeToLength(['a', 'b', 'c'], 3),
['a', 'b', 'c']
)

self.assertEqual(
resizeToLength([1, 2, 3], 1),
[3]
)

self.assertEqual(
resizeToLength([], 3),
[0, 0, 0]
)

with self.assertRaises(AssertionError):
resizeToLength([], -1)

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

0 comments on commit 2ba3a79

Please sign in to comment.