blob: 3d09b550ab2b5231099bb739feafe0bb92f2c20a [file] [log] [blame]
# Copyright 2023 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Test the textproto module."""
import pytest
from chromite.format import formatters
# None means input is already formatted to avoid having to repeat.
@pytest.mark.parametrize(
"data,exp",
(
("", None),
("\n FOO {}\n\n\n", "FOO {}\n"),
("FOO { BAR { blah: 1 }\n}", "FOO {\n BAR { blah: 1 }\n}\n"),
),
)
def test_check_format(data, exp) -> None:
"""Verify inputs match expected outputs."""
if exp is None:
exp = data
assert exp == formatters.textproto.Data(data)
@pytest.mark.parametrize(
"data",
('"',),
)
def test_format_failures(data) -> None:
"""Verify inputs raise ParseErrors as expected."""
with pytest.raises(formatters.ParseError):
formatters.textproto.Data(data)