test_line_segment.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 (
  12. repr(LineSegment((67018, 67019)))
  13. == "LineSegment(vertex_indices=(67018, 67019))"
  14. )
  15. def test_adjacent_vertex_indices_1():
  16. chain = LineSegment((1, 4))
  17. singles = list(chain.adjacent_vertex_indices(1))
  18. assert len(singles) == 2
  19. assert singles[0] == (1,)
  20. assert singles[1] == (4,)
  21. def test_adjacent_vertex_indices_2():
  22. chain = LineSegment((1, 4))
  23. pairs = list(chain.adjacent_vertex_indices(2))
  24. assert len(pairs) == 2
  25. assert pairs[0] == (1, 4)
  26. assert pairs[1] == (4, 1)
  27. def test_adjacent_vertex_indices_3():
  28. chain = LineSegment((1, 4))
  29. triplets = list(chain.adjacent_vertex_indices(3))
  30. assert len(triplets) == 2
  31. assert triplets[0] == (1, 4, 1)
  32. assert triplets[1] == (4, 1, 4)