NordicSemiconductor / IOS-CoreBluetooth-Mock

Mocking library for CoreBluetooth framework.
BSD 3-Clause "New" or "Revised" License
225 stars 51 forks source link

fix issue not reporting complete list when supplying empty filter list #69

Closed kscheff closed 2 years ago

kscheff commented 2 years ago

Fix issue #68 not returning entire list when no filter for discovering services, characteristics

CLAassistant commented 2 years ago

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


Kai Scheffer seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

philips77 commented 2 years ago

Hi, I don't understand. If servicesis empty, then

!services!.contains { ds in s.identifier == ds.identifier }

in

            let initialSize = services!.count
            services = services! + mockServices
                // Filter all device services that match given list (if set).
                .filter { serviceUUIDs?.contains($0.uuid) ?? true }
                // Filter those of them, that are not already in discovered services.
                .filter { s in !services!
                    .contains { ds in s.identifier == ds.identifier }
                  || initialSize == 0
                }
                ...

returns true...