From 2ba3a793ccafd69e5a1537f4dc8ce8e488f3ed72 Mon Sep 17 00:00:00 2001 From: eir Date: Mon, 18 Nov 2019 13:18:00 -0800 Subject: [PATCH] utility/resizeToLength: Add test --- tests/test_utility.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/test_utility.py b/tests/test_utility.py index ca3628b..7fb08c6 100644 --- a/tests/test_utility.py +++ b/tests/test_utility.py @@ -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()