coverage
読み取り中…
検索中…
一致する文字列を見つけられません
test_zone_field.py
[詳解]
1"""zone_fieldの座標検証と正規化の契約を検証する。"""
2
3import pytest
4
5from coverage.zone_field import NormalizedZone, normalize_zone
6
7
9 pts = [(0.0, 0.0), (2.0, 0.0), (2.0, 1.0), (0.0, 1.0)]
10 assert normalize_zone(pts) == pts
11
12
14 pts = [(0.0, 0.0), (2.0, 0.0), (2.0, 1.0), (0.0, 1.0), (0.0, 0.0)]
15 assert normalize_zone(pts) == pts[:4]
16
17
19 with pytest.raises(ValueError):
20 normalize_zone([(0.0, 0.0), (1.0, 0.0)])
21
22
24 with pytest.raises(ValueError):
25 normalize_zone([])
26
27
29 with pytest.raises(ValueError):
30 normalize_zone([(0.0, 0.0), (float('nan'), 0.0), (0.0, 1.0)])
31 with pytest.raises(ValueError):
32 normalize_zone([(0.0, 0.0), (float('inf'), 0.0), (0.0, 1.0)])
33
34
36 # 頂点順序は入力値のまま保持する。
37 pts = [(2.0, 1.0), (0.0, 0.0), (0.0, 1.0), (2.0, 0.0)]
38 assert normalize_zone(pts) == pts
39
40
42 source = [(0.0, 0.0), (2.0, 0.0), (2.0, 1.0), (0.0, 0.0)]
43 zone = NormalizedZone.from_points('map', source)
44
45 source[0] = (99.0, 99.0)
46
47 assert zone.frame_id == 'map'
48 assert zone.points == ((0.0, 0.0), (2.0, 0.0), (2.0, 1.0))
49
50
52 with pytest.raises(ValueError, match='numeric x/y'):
53 normalize_zone([(0.0, 0.0), (1.0,), (0.0, 1.0)])
清掃ゾーンの点列をROSメッセージに依存せず検証・正規化する。