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([])
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"])
def test_public_properties__filter_match(objc_class): result = [ m.name for m in public_properties(objc_class, InsertionFilter( members="Public")) ] assert result == ["PublicProperty"]
def test_public_variables__filter_match(cpp_class): result = [ m.name for m in public_variables(cpp_class, InsertionFilter( members=".*Var.*")) ] assert result == ["PublicVariable"]
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"])
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", ])
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" ])
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"]
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("_"))
def public_constructors(element, insert_filter: InsertionFilter): return (m for m in insert_filter.members(element) if m.kind == "function" and m.name == "__init__")
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
def test_public_destructors__filter_no_match(helper): helper.insert_filter = InsertionFilter(members="OtherClass") result = list(helper.destructors(prot="public")) assert len(result) == 0
def helper(empty_generating_api, cpp_class): return CppTemplateHelper(empty_generating_api, cpp_class, InsertionFilter())
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
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++"]
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__"])
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"
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__"])
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"]
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"])
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))
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"])
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("_"))
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
def helper(java_class, empty_generating_api): return JavaTemplateHelper(empty_generating_api, java_class, InsertionFilter())
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"])
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
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"])