custom_order_test.py
Go to the documentation of this file.
1 import pytest
2 import fields2cover as f2c
3 
4 PARAMETRIZED_INPUTS = [
5  (5, [0, 1, 2, 3, 4], [0, 1, 2, 3, 4]),
6  (10, range(10), range(10))
7 ]
8 
9 PARAMETRIZED_INPUTS_WRONG = [
10  (5, [0, 1, 2, 3, 4], [1, 2, 3, 4, 5]),
11  (5, [0, 1, 2, 3, 4], [1, 1, 2, 2, 4]),
12  (10, range(10), range(1,11))
13 ]
14 
15 @pytest.mark.parametrize('n,custom_order,expected', PARAMETRIZED_INPUTS)
16 def test_fields2cover_custom_order(n, custom_order, expected):
17  swaths = f2c.Swaths()
18  for i in range(n):
19  swaths.push_back(
20  f2c.Swath(
21  f2c.LineString(
22  f2c.VectorPoint([
23  f2c.Point(0, i),
24  f2c.Point(1, i)])),
25  1,
26  i
27  )
28  )
29  swath_order = f2c.RP_CustomOrder(f2c.VectorSize(custom_order))
30  swaths = swath_order.genSortedSwaths(swaths)
31 
32  actual = [swaths.at(i).getId() for i in range(swaths.size())]
33  assert len(actual) == len(expected)
34  assert all(a == b for a, b in zip(actual, expected))
35 
36 @pytest.mark.parametrize('n,custom_order,expected', PARAMETRIZED_INPUTS_WRONG)
37 def test_fields2cover_wrong_custom_order(n, custom_order, expected):
38  swaths = f2c.Swaths()
39  for i in range(n):
40  swaths.push_back(
41  f2c.Swath(
42  f2c.LineString(
43  f2c.VectorPoint([f2c.Point(0, i),
44  f2c.Point(1, i)])), 1, i))
45  swath_order = f2c.RP_CustomOrder(f2c.VectorSize(custom_order))
46  swaths = swath_order.genSortedSwaths(swaths)
47  actual = [swaths.at(i).getId() for i in range(swaths.size())]
48  assert any(a != b for a, b in zip(actual, expected))
49 
custom_order_test.test_fields2cover_custom_order
def test_fields2cover_custom_order(n, custom_order, expected)
Definition: custom_order_test.py:16
custom_order_test.test_fields2cover_wrong_custom_order
def test_fields2cover_wrong_custom_order(n, custom_order, expected)
Definition: custom_order_test.py:37


fields2cover
Author(s):
autogenerated on Fri Apr 25 2025 02:18:31