# Path: symsynd/demangle.py
# def demangle_swift_symbol(symbol, simplified=False):
#     return _demangle(lib.demangle_swift, symbol, simplified=simplified)
# 
# def demangle_cpp_symbol(symbol, simplified=False):
#     return _demangle(lib.demangle_cpp, symbol, simplified=simplified)


from symsynd import demangle_swift_symbol, demangle_cpp_symbol
    default_expected = (
        u'protocol witness for static Swift._ObjectiveCBridgeable._'
        u'unconditionallyBridgeFromObjectiveC (Swift.Optional<A._'
        u'ObjectiveCType>) -> A in conformance __C.'
        u'UIApplicationLaunchOptionsKey : Swift._ObjectiveCBridgeable '
        u'in UIKit'
    )
    simplified_expected = (
        u'protocol witness for static _ObjectiveCBridgeable._'
        u'unconditionallyBridgeFromObjectiveC(A._ObjectiveCType?) -> '
        u'A in conformance UIApplicationLaunchOptionsKey'
    )

    assert demangle_swift_symbol(mangled) == default_expected
    assert demangle_swift_symbol(mangled, simplified=True) == simplified_expected


def test_cpp_demangle():
    mangled = '_ZN6google8protobuf2io25CopyingInputStreamAdaptor4SkipEi'
    expected = 'google::protobuf::io::CopyingInputStreamAdaptor::Skip(int)'
    assert demangle_cpp_symbol(mangled) == expected


def test_demangle_failure_underscore():
    mangled = '_some_name'
    assert demangle_swift_symbol(mangled) is None


def test_demangle_failure_no_underscore():
    mangled = 'some_other_name'

# Path: symsynd/demangle.py
# def demangle_swift_symbol(symbol, simplified=False):
#     return _demangle(lib.demangle_swift, symbol, simplified=simplified)
# 
# def demangle_cpp_symbol(symbol, simplified=False):
#     return _demangle(lib.demangle_cpp, symbol, simplified=simplified)


# Path: tests/test_demangle.py
from symsynd import demangle_swift_symbol, demangle_cpp_symbol

    default_expected = (
        u'protocol witness for static Swift._ObjectiveCBridgeable._'
        u'unconditionallyBridgeFromObjectiveC (Swift.Optional<A._'
        u'ObjectiveCType>) -> A in conformance __C.'
        u'UIApplicationLaunchOptionsKey : Swift._ObjectiveCBridgeable '
        u'in UIKit'
    )
    simplified_expected = (
        u'protocol witness for static _ObjectiveCBridgeable._'
        u'unconditionallyBridgeFromObjectiveC(A._ObjectiveCType?) -> '
        u'A in conformance UIApplicationLaunchOptionsKey'
    )

    assert demangle_swift_symbol(mangled) == default_expected
    assert demangle_swift_symbol(mangled, simplified=True) == simplified_expected


def test_cpp_demangle():
    mangled = '_ZN6google8protobuf2io25CopyingInputStreamAdaptor4SkipEi'
    expected = 'google::protobuf::io::CopyingInputStreamAdaptor::Skip(int)'
    assert demangle_cpp_symbol(mangled) == expected


def test_demangle_failure_underscore():
    mangled = '_some_name'
    assert demangle_swift_symbol(mangled) is None


def test_demangle_failure_no_underscore():
    mangled = 'some_other_name'

    assert demangle_swift_symbol(mangled) is None