coverage
Toggle main menu visibility
読み取り中…
検索中…
一致する文字列を見つけられません
test_zone_field.py
[詳解]
1
"""zone_fieldの座標検証と正規化の契約を検証する。"""
2
3
import
pytest
4
5
from
coverage.zone_field
import
NormalizedZone, normalize_zone
6
7
8
def
test_square_ok
():
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
13
def
test_closing_duplicate_removed
():
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
18
def
test_too_few_vertices_raises
():
19
with
pytest.raises(ValueError):
20
normalize_zone([(0.0, 0.0), (1.0, 0.0)])
21
22
23
def
test_empty_raises
():
24
with
pytest.raises(ValueError):
25
normalize_zone([])
26
27
28
def
test_non_finite_raises
():
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
35
def
test_order_preserved
():
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
41
def
test_normalized_zone_is_an_immutable_snapshot
():
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
51
def
test_malformed_point_raises_value_error
():
52
with
pytest.raises(ValueError, match=
'numeric x/y'
):
53
normalize_zone([(0.0, 0.0), (1.0,), (0.0, 1.0)])
coverage.zone_field
清掃ゾーンの点列をROSメッセージに依存せず検証・正規化する。
定義
zone_field.py:1
test_zone_field.test_empty_raises
test_empty_raises()
定義
test_zone_field.py:23
test_zone_field.test_non_finite_raises
test_non_finite_raises()
定義
test_zone_field.py:28
test_zone_field.test_order_preserved
test_order_preserved()
定義
test_zone_field.py:35
test_zone_field.test_square_ok
test_square_ok()
定義
test_zone_field.py:8
test_zone_field.test_closing_duplicate_removed
test_closing_duplicate_removed()
定義
test_zone_field.py:13
test_zone_field.test_normalized_zone_is_an_immutable_snapshot
test_normalized_zone_is_an_immutable_snapshot()
定義
test_zone_field.py:41
test_zone_field.test_malformed_point_raises_value_error
test_malformed_point_raises_value_error()
定義
test_zone_field.py:51
test_zone_field.test_too_few_vertices_raises
test_too_few_vertices_raises()
定義
test_zone_field.py:18
test
test_zone_field.py
構築:
1.18.0