test_line_segment.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import pytest
  2. from freesurfer_surface import LineSegment
  3. def test_init_fail():
  4. with pytest.raises(Exception):
  5. LineSegment((1, 2, 3))
  6. def test_eq():
  7. assert LineSegment((67018, 67019)) == LineSegment((67018, 67019))
  8. assert LineSegment((67018, 67019)) == LineSegment((67019, 67018))
  9. assert LineSegment((67019, 67018)) == LineSegment((67018, 67019))
  10. def test_repr():
  11. assert repr(LineSegment((67018, 67019))) \
  12. == 'LineSegment(vertex_indices=(67018, 67019))'
  13. def test_adjacent_vertex_indices_1():
  14. chain = LineSegment((1, 4))
  15. singles = list(chain.adjacent_vertex_indices(1))
  16. assert len(singles) == 2
  17. assert singles[0] == (1,)
  18. assert singles[1] == (4,)
  19. def test_adjacent_vertex_indices_2():
  20. chain = LineSegment((1, 4))
  21. pairs = list(chain.adjacent_vertex_indices(2))
  22. assert len(pairs) == 2
  23. assert pairs[0] == (1, 4)
  24. assert pairs[1] == (4, 1)
  25. def test_adjacent_vertex_indices_3():
  26. chain = LineSegment((1, 4))
  27. triplets = list(chain.adjacent_vertex_indices(3))
  28. assert len(triplets) == 2
  29. assert triplets[0] == (1, 4, 1)
  30. assert triplets[1] == (4, 1, 4)