diff options
| author | Raghuram Subramani <raghus2247@gmail.com> | 2022-06-19 19:47:51 +0530 |
|---|---|---|
| committer | Raghuram Subramani <raghus2247@gmail.com> | 2022-06-19 19:47:51 +0530 |
| commit | 4fd287655a72b9aea14cdac715ad5b90ed082ed2 (patch) | |
| tree | 65d393bc0e699dd12d05b29ba568e04cea666207 /circuitpython/tools/huffman/tests/test_util.py | |
| parent | 0150f70ce9c39e9e6dd878766c0620c85e47bed0 (diff) | |
add circuitpython code
Diffstat (limited to 'circuitpython/tools/huffman/tests/test_util.py')
| -rw-r--r-- | circuitpython/tools/huffman/tests/test_util.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/circuitpython/tools/huffman/tests/test_util.py b/circuitpython/tools/huffman/tests/test_util.py new file mode 100644 index 0000000..099d009 --- /dev/null +++ b/circuitpython/tools/huffman/tests/test_util.py @@ -0,0 +1,39 @@ +from __future__ import absolute_import, print_function + +import random +import unittest + +from .util import is_sorted, popper + +class TestIsSorted(unittest.TestCase): + + def test_is_sorted(self): + assert is_sorted([1]) + assert is_sorted([1, 2]) + assert is_sorted([1, 2, 3]) + assert is_sorted([1, 2, 2]) + assert is_sorted([2, 2, 2]) + assert is_sorted([]) + assert is_sorted((1, 2, 3)) + assert is_sorted('abc') + assert is_sorted('123') + assert is_sorted('eggs') + assert is_sorted(iter([1, 2, 3])) + + def test_is_not_sorted(self): + assert not is_sorted([3, 2, 1]) + assert not is_sorted([2, 2, 1]) + assert not is_sorted('spam') + + +class TestPopper(unittest.TestCase): + + def test_popper(self): + for i in range(10): + x = list(range(i)) + + j = 0 + for _ in popper(x): + j += 1 + + self.assertEqual(i, j) |
