test_bidirectional_iterator.py 640 B

1234567891011121314151617181920212223242526272829303132
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. __author__ = "heider"
  4. __doc__ = r"""
  5. Created on 8/10/22
  6. """
  7. __all__ = []
  8. from draugr.python_utilities.iterators import BidirectionalIterator, prev
  9. def test_bidirectional_iterator():
  10. a = BidirectionalIterator(iter([1, 2, 3, 4, 5, 6]))
  11. assert next(a) == 1
  12. assert next(a) == 2
  13. assert next(a) == 3
  14. assert next(a) == 4
  15. assert next(a) == 5
  16. assert next(a) == 6
  17. assert prev(a) == 5
  18. assert prev(a) == 4
  19. assert prev(a) == 3
  20. assert prev(a) == 2
  21. assert prev(a) == 1
  22. if __name__ == "__main__":
  23. test_bidirectional_iterator()