def test_insertion_filter__compound__filter_members(cpp_class):
    insertion_filter = InsertionFilter(members={"kind": "variable"})

    member_names = [
        member.name for member in insertion_filter.members(cpp_class)
    ]
    assert sorted(member_names) == sorted([
        "PublicVariable",
        "ProtectedVariable",
        "PrivateVariable",
    ])
def test_insertion_filer__member__exceptions__filter_name(api_reference):
    member = api_reference.find(
        "asciidoxy::traffic::TrafficEvent::CalculateDelay")
    assert member is not None

    insertion_filter = InsertionFilter(exceptions="NONE")

    exception_names = [
        exception.type.name
        for exception in insertion_filter.exceptions(member)
    ]
    assert sorted(exception_names) == sorted([])
Exemple #3
0
def test_public_simple_enclosed_types__filter_match(cpp_class):
    simple_enclosed_types = [
        m.name for m in public_simple_enclosed_types(
            cpp_class, InsertionFilter(members=".*Typedef"))
    ]
    assert sorted(simple_enclosed_types) == sorted(
        ["PublicTypedef", "ProtectedTypedef"])
Exemple #4
0
def test_public_properties__filter_match(objc_class):
    result = [
        m.name
        for m in public_properties(objc_class, InsertionFilter(
            members="Public"))
    ]
    assert result == ["PublicProperty"]
Exemple #5
0
def test_public_variables__filter_match(cpp_class):
    result = [
        m.name
        for m in public_variables(cpp_class, InsertionFilter(
            members=".*Var.*"))
    ]
    assert result == ["PublicVariable"]
Exemple #6
0
def test_public_simple_enclosed_types__no_filter(cpp_class):
    simple_enclosed_types = [
        m.name
        for m in public_simple_enclosed_types(cpp_class, InsertionFilter())
    ]
    assert sorted(simple_enclosed_types) == sorted(
        ["PublicEnum", "PublicTypedef", "ProtectedEnum", "ProtectedTypedef"])
Exemple #7
0
def test_public_simple_enclosed_types__filter_match(objc_class):
    result = [
        m.name for m in public_simple_enclosed_types(
            objc_class, InsertionFilter(members=".*Enum"))
    ]
    assert sorted(result) == sorted([
        "PublicEnum",
        "ProtectedEnum",
        "PrivateEnum",
    ])
Exemple #8
0
def test_public_simple_enclosed_types__no_filter(objc_class):
    result = [
        m.name
        for m in public_simple_enclosed_types(objc_class, InsertionFilter())
    ]
    assert sorted(result) == sorted([
        "PublicEnum", "ProtectedEnum", "PrivateEnum", "PublicClass",
        "ProtectedClass", "PrivateClass", "PublicProtocol",
        "ProtectedProtocol", "PrivateProtocol"
    ])
def test_insertion_filter__compound__no_filters(cpp_class):
    insertion_filter = InsertionFilter()

    member_names = [
        member.name for member in insertion_filter.members(cpp_class)
    ]
    assert sorted(member_names) == sorted([
        "PublicVariable", "PublicEnum", "PublicClass", "PublicTypedef",
        "PublicStruct", "PublicTrash", "PublicEnumvalue", "MyClass", "MyClass",
        "MyClass", "MyClass", "MyClass", "MyClass", "MyClass", "operator++",
        "PublicMethod", "PublicStaticMethod", "ProtectedVariable",
        "ProtectedEnum", "ProtectedClass", "ProtectedTypedef",
        "ProtectedStruct", "ProtectedTrash", "ProtectedEnumvalue", "MyClass",
        "operator++", "ProtectedMethod", "ProtectedStaticMethod",
        "PrivateVariable", "PrivateEnum", "PrivateClass", "PrivateTypedef",
        "PrivateStruct", "PrivateTrash", "PrivateEnumvalue", "MyClass",
        "operator++", "PrivateMethod", "PrivateStaticMethod", "operator=",
        "operator=", "operator=", "operator=", "operator=", "operator=",
        "~MyClass", "~MyClass", "~MyClass"
    ])
Exemple #10
0
def test_public_constants__filter_match(helper):
    helper.insert_filter = InsertionFilter(members="Public")
    result = [m.name for m in helper.constants(prot="public")]
    assert result == ["PublicConstant"]
Exemple #11
0
def public_variables(element, insert_filter: InsertionFilter):
    return (m for m in insert_filter.members(element)
            if m.kind == "variable" and not m.name.startswith("_"))
Exemple #12
0
def public_constructors(element, insert_filter: InsertionFilter):
    return (m for m in insert_filter.members(element)
            if m.kind == "function" and m.name == "__init__")
Exemple #13
0
def test_public_methods__filter_no_match(helper):
    helper.insert_filter = InsertionFilter(members="PublicThing")
    result = [m.name for m in helper.methods(prot="public")]
    assert len(result) == 0
Exemple #14
0
def test_public_destructors__filter_no_match(helper):
    helper.insert_filter = InsertionFilter(members="OtherClass")
    result = list(helper.destructors(prot="public"))
    assert len(result) == 0
Exemple #15
0
def helper(empty_generating_api, cpp_class):
    return CppTemplateHelper(empty_generating_api, cpp_class,
                             InsertionFilter())
Exemple #16
0
def test_public_variables__filter_no_match(python_class):
    result = list(m.name for m in public_variables(python_class, InsertionFilter(members="NONE")))
    assert not result
Exemple #17
0
def test_public_operators__filter_match(helper):
    helper.insert_filter = InsertionFilter(members="ALL")
    result = [m.name for m in helper.operators(prot="public")]
    assert result == ["operator++"]
Exemple #18
0
def test_public_constructors__no_filter(python_class):
    result = list(m.name for m in public_constructors(python_class, InsertionFilter()))
    assert sorted(result) == sorted(["__init__"])
Exemple #19
0
def test_public_destructors__filter_match(helper):
    helper.insert_filter = InsertionFilter(members="~MyClass")
    result = list(helper.destructors(prot="public"))
    assert len(result) == 1
    assert result[0].name == "~MyClass"
    assert result[0].prot == "public"
Exemple #20
0
def test_public_constructors__filter_match(python_class):
    result = list(m.name for m in public_constructors(python_class, InsertionFilter(members="ALL")))
    assert sorted(result) == sorted(["__init__"])
Exemple #21
0
def test_public_methods__filter_match(helper):
    helper.insert_filter = InsertionFilter(members="Public.*")
    result = [m.name for m in helper.methods(prot="public")]
    assert result == ["PublicMethod"]
Exemple #22
0
def test_public_enclosed_types__no_filter(python_class):
    result = list(m.name for m in public_enclosed_types(python_class, InsertionFilter()))
    assert sorted(result) == sorted(["NestedClass"])
Exemple #23
0
def public_methods(element, insert_filter: InsertionFilter):
    return (m for m in insert_filter.members(element)
            if (m.kind == "function" and m.returns
                and not m.name.startswith("_") and not m.static))
Exemple #24
0
def test_public_enclosed_types__filter_match(python_class):
    result = list(
        m.name for m in public_enclosed_types(python_class, InsertionFilter(inner_classes="ALL")))
    assert sorted(result) == sorted(["NestedClass"])
Exemple #25
0
def public_enclosed_types(element, insert_filter: InsertionFilter):
    return (m.referred_object for m in insert_filter.inner_classes(element)
            if m.referred_object is not None and not m.name.startswith("_"))
Exemple #26
0
def test_public_enclosed_types__filter_no_match(python_class):
    result = list(
        m.name for m in public_enclosed_types(python_class, InsertionFilter(inner_classes="NONE")))
    assert not result
Exemple #27
0
def helper(java_class, empty_generating_api):
    return JavaTemplateHelper(empty_generating_api, java_class,
                              InsertionFilter())
Exemple #28
0
def test_public_variables__no_filter(python_class):
    result = list(m.name for m in public_variables(python_class, InsertionFilter()))
    assert sorted(result) == sorted(["public_variable"])
Exemple #29
0
def test_public_constants__filter_no_match(helper):
    helper.insert_filter = InsertionFilter(members="NONE")
    result = [m.name for m in helper.constants(prot="public")]
    assert len(result) == 0
Exemple #30
0
def test_public_variables__filter_match(python_class):
    result = list(m.name for m in public_variables(python_class, InsertionFilter(members="ALL")))
    assert sorted(result) == sorted(["public_variable"])