|
@@ -18,6 +18,28 @@ def test_reassign_vertex_indices():
|
|
assert tuple(chain.vertex_indices) == (1, 2, 3, 4)
|
|
assert tuple(chain.vertex_indices) == (1, 2, 3, 4)
|
|
|
|
|
|
|
|
|
|
|
|
+@pytest.mark.parametrize(
|
|
|
|
+ ("indices_init", "indices_normalized"),
|
|
|
|
+ (
|
|
|
|
+ ([0, 3], [0, 3]),
|
|
|
|
+ ([3, 0], [0, 3]),
|
|
|
|
+ ([0, 3, 2, 4], [0, 3, 2, 4]),
|
|
|
|
+ ([0, 4, 2, 3], [0, 3, 2, 4]),
|
|
|
|
+ ([2, 3, 0, 4], [0, 3, 2, 4]),
|
|
|
|
+ ([2, 4, 0, 3], [0, 3, 2, 4]),
|
|
|
|
+ ([3, 0, 4, 2], [0, 3, 2, 4]),
|
|
|
|
+ ([3, 2, 4, 0], [0, 3, 2, 4]),
|
|
|
|
+ ([4, 0, 3, 2], [0, 3, 2, 4]),
|
|
|
|
+ ([4, 2, 3, 0], [0, 3, 2, 4]),
|
|
|
|
+ ),
|
|
|
|
+)
|
|
|
|
+def test_normalized(indices_init, indices_normalized):
|
|
|
|
+ assert (
|
|
|
|
+ list(PolygonalChain(indices_init).normalized().vertex_indices)
|
|
|
|
+ == indices_normalized
|
|
|
|
+ )
|
|
|
|
+
|
|
|
|
+
|
|
def test_eq():
|
|
def test_eq():
|
|
assert PolygonalChain((0, 1, 2)) == PolygonalChain((0, 1, 2))
|
|
assert PolygonalChain((0, 1, 2)) == PolygonalChain((0, 1, 2))
|
|
|
|
|
|
@@ -27,6 +49,14 @@ def test_eq():
|
|
assert not PolygonalChain((0, 1, 2)) == PolygonalChain((1, 2, 3, 4))
|
|
assert not PolygonalChain((0, 1, 2)) == PolygonalChain((1, 2, 3, 4))
|
|
|
|
|
|
|
|
|
|
|
|
+def test_eq_normalized():
|
|
|
|
+ assert PolygonalChain((0, 1, 2)) == PolygonalChain((0, 2, 1))
|
|
|
|
+ assert PolygonalChain((1, 0, 2)) == PolygonalChain((0, 2, 1))
|
|
|
|
+ assert PolygonalChain((1, 0, 2, 4)) == PolygonalChain((0, 1, 4, 2))
|
|
|
|
+
|
|
|
|
+ assert not PolygonalChain((1, 0, 2, 4)) == PolygonalChain((0, 1, 2, 4))
|
|
|
|
+
|
|
|
|
+
|
|
def test_repr():
|
|
def test_repr():
|
|
assert repr(PolygonalChain([])) == "PolygonalChain(vertex_indices=())"
|
|
assert repr(PolygonalChain([])) == "PolygonalChain(vertex_indices=())"
|
|
assert repr(PolygonalChain((0, 2, 1))) == "PolygonalChain(vertex_indices=(0, 2, 1))"
|
|
assert repr(PolygonalChain((0, 2, 1))) == "PolygonalChain(vertex_indices=(0, 2, 1))"
|
|
@@ -57,10 +87,7 @@ def test_connect(vertex_indices_a, vertex_indices_b, expected_vertex_indices):
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
@pytest.mark.parametrize(
|
|
- ("vertex_indices_a", "vertex_indices_b"),
|
|
+ ("vertex_indices_a", "vertex_indices_b"), [((1, 2, 3), (2, 4))]
|
|
- [
|
|
|
|
- ((1, 2, 3), (2, 4)),
|
|
|
|
- ],
|
|
|
|
)
|
|
)
|
|
def test_connect_fail(vertex_indices_a, vertex_indices_b):
|
|
def test_connect_fail(vertex_indices_a, vertex_indices_b):
|
|
chain = PolygonalChain(vertex_indices_a)
|
|
chain = PolygonalChain(vertex_indices_a)
|
|
@@ -69,11 +96,7 @@ def test_connect_fail(vertex_indices_a, vertex_indices_b):
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
@pytest.mark.parametrize(
|
|
- ("vertex_indices_a", "vertex_indices_b"),
|
|
+ ("vertex_indices_a", "vertex_indices_b"), [((1, 2, 3), ()), ((), (3, 4))]
|
|
- [
|
|
|
|
- ((1, 2, 3), ()),
|
|
|
|
- ((), (3, 4)),
|
|
|
|
- ],
|
|
|
|
)
|
|
)
|
|
def test_connect_fail_empty(vertex_indices_a, vertex_indices_b):
|
|
def test_connect_fail_empty(vertex_indices_a, vertex_indices_b):
|
|
chain = PolygonalChain(vertex_indices_a)
|
|
chain = PolygonalChain(vertex_indices_a)
|