test_polygonal_circuit.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import pytest
  2. from freesurfer_surface import _PolygonalCircuit
  3. @pytest.mark.parametrize(('source_vertex_indices', 'expected_vertex_indices'), [
  4. ((1, 2, 3), (1, 2, 3)),
  5. ((2, 3, 1), (1, 2, 3)),
  6. ((3, 1, 2), (1, 2, 3)),
  7. ((1,), (1,)),
  8. ])
  9. def test__normalize(source_vertex_indices, expected_vertex_indices):
  10. # pylint: disable=protected-access
  11. circuit = _PolygonalCircuit(source_vertex_indices)
  12. assert expected_vertex_indices == circuit._normalize()._vertex_indices
  13. def test_eq():
  14. assert _PolygonalCircuit((0, 1)) == _PolygonalCircuit((0, 1))
  15. assert _PolygonalCircuit((0, 1)) == _PolygonalCircuit((1, 0))
  16. assert _PolygonalCircuit((0, 1, 2)) == _PolygonalCircuit((0, 1, 2))
  17. assert _PolygonalCircuit((0, 1, 2)) == _PolygonalCircuit((1, 2, 0))
  18. assert _PolygonalCircuit((0, 1, 2)) == _PolygonalCircuit((2, 0, 1))
  19. # pylint: disable=unneeded-not
  20. assert not _PolygonalCircuit((0, 1, 2)) == _PolygonalCircuit((0, 1, 4))
  21. assert not _PolygonalCircuit((0, 1, 2)) == _PolygonalCircuit((0, 4, 2))
  22. assert not _PolygonalCircuit((0, 1, 2)) == _PolygonalCircuit((4, 1, 2))
  23. def test_hash():
  24. assert hash(_PolygonalCircuit((0, 1, 2))) \
  25. == hash(_PolygonalCircuit((0, 1, 2)))
  26. assert hash(_PolygonalCircuit((0, 1, 2))) \
  27. == hash(_PolygonalCircuit((1, 2, 0)))
  28. assert hash(_PolygonalCircuit((0, 1, 2))) \
  29. == hash(_PolygonalCircuit((2, 0, 1)))
  30. assert hash(_PolygonalCircuit((0, 1, 2))) \
  31. != hash(_PolygonalCircuit((0, 1, 4)))
  32. assert hash(_PolygonalCircuit((0, 1, 2))) \
  33. != hash(_PolygonalCircuit((0, 4, 2)))
  34. assert hash(_PolygonalCircuit((0, 1, 2))) \
  35. != hash(_PolygonalCircuit((4, 1, 2)))