fix(map): require single-character legend keys
This commit is contained in:
@@ -93,6 +93,26 @@ def test_rejects_char_missing_from_legend(tmp_path: Path) -> None:
|
||||
load_map(_write(tmp_path, body))
|
||||
|
||||
|
||||
def test_rejects_multi_character_legend_key(tmp_path: Path) -> None:
|
||||
"""One char = one square: a legend key like "ZZ" can never match a cell
|
||||
and is dead data -- reject it at load."""
|
||||
body = _minimal_map().replace(
|
||||
' ".": { type: floor, move_cost: 1 }\n',
|
||||
' ".": { type: floor, move_cost: 1 }\n "ZZ": { type: floor, move_cost: 1 }\n',
|
||||
)
|
||||
with pytest.raises(MapValidationError, match="legend keys must be exactly one character"):
|
||||
load_map(_write(tmp_path, body))
|
||||
|
||||
|
||||
def test_rejects_empty_legend_key(tmp_path: Path) -> None:
|
||||
body = _minimal_map().replace(
|
||||
' ".": { type: floor, move_cost: 1 }\n',
|
||||
' "": { type: floor, move_cost: 1 }\n',
|
||||
)
|
||||
with pytest.raises(MapValidationError, match="legend keys must be exactly one character"):
|
||||
load_map(_write(tmp_path, body))
|
||||
|
||||
|
||||
def test_rejects_elevation_dimension_mismatch(tmp_path: Path) -> None:
|
||||
body = _minimal_map() + "elevation: |\n 000\n 00\n"
|
||||
with pytest.raises(MapValidationError):
|
||||
|
||||
Reference in New Issue
Block a user