def test_kind_in():
    # when:
    kind = ParameterKind.kind_in()

    # then:
    assert kind.is_in()
    assert not kind.is_out()
def test_parse_fixed_length(text, fixed_length):
    # when:
    parameter_documentation = ParameterDocumentation.from_param_string(text)

    # then:
    assert parameter_documentation.identifier == 'test'
    assert parameter_documentation.kind == ParameterKind.kind_in()
    assert parameter_documentation.fixed_length == fixed_length
def test_parse_null_terminated():
    # given:
    text = '@param[in, null-terminated] value'

    # when:
    parameter_documentation = ParameterDocumentation.from_param_string(text)

    # then:
    assert parameter_documentation.identifier == 'value'
    assert parameter_documentation.kind == ParameterKind.kind_in()
    assert parameter_documentation.fixed_length is None
    assert parameter_documentation.null_terminated
def test_enrich_with_documentation_defaults():
    # given:
    parameter = Parameter('abc', 'def', SimpleType('int'))
    parameter_documentation = create_parameter_documentation('abc')

    # when:
    parameter.enrich_with_documentation(parameter_documentation)

    # then:
    assert parameter.kind == ParameterKind.kind_in()
    assert parameter.is_input
    assert not parameter.is_not_input
    assert not parameter.is_output
    assert parameter.has_simple_type
    assert not parameter.has_pointer_type
    assert not parameter.is_single_element
    assert not parameter.has_fixed_length
    assert parameter.fixed_length is None
    assert not parameter.is_null_terminated
    assert not parameter.has_length_descriptor
    assert parameter.length_descriptor is None
import pytest

from c_mock_generator.module_definition.exceptions import MockGeneratorError
from c_mock_generator.module_definition.parameter_documentation import \
    ParameterDocumentation, ActiveAttributions, parse_param_annotation
from c_mock_generator.module_definition.parameter_kind import ParameterKind


@pytest.mark.parametrize('text,identifier,kind', [
    ('@param abc', 'abc', None),
    ('@param abc The ABC', 'abc', None),
    ('@param[in] abc The ABC', 'abc', ParameterKind.kind_in()),
    ('@param[out] abc The ABC', 'abc', ParameterKind.kind_out()),
    ('@param[inout] abc The ABC', 'abc', ParameterKind.kind_in_out()),
])
def test_from_param_string(text, identifier, kind):
    # when:
    parameter_documentation = ParameterDocumentation.from_param_string(text)

    # then:
    assert parameter_documentation.identifier == identifier
    if kind is None:
        assert parameter_documentation.kind is None
    else:
        assert parameter_documentation.kind == kind
    assert parameter_documentation.fixed_length is None
    assert not parameter_documentation.null_terminated
    assert parameter_documentation.length_descriptor is None


@pytest.mark.parametrize('text', [