DrAma999 / LittleBlueTooth

A simple library that helps you in connecting with BLE devices
MIT License
79 stars 17 forks source link

Fix for assertion tripping on 3 variadic args #26

Closed rolandhordos closed 2 years ago

rolandhordos commented 2 years ago

Fix for crash due to assertion when more than 2 variadic args are passed to Loggable.log().

This is where 3 args are used in LittleBlueTooth private func restore shown here.

I added a test to UtilityTest.swift for it, so I moved the assertion out of the conditional compilation !TEST region so it applies under test. I think this still supports what I imagine the intent of TEST is, to avoid cluttering output under test.

An additional test for the failure condition (4+ args) is not possible without some brittle trickery, replacing assert behaviour, so skipped that and simply manually verified that 4 arg would trip the assert().

I tested the branch under near identical conditions to further verify the fix.

rolandhordos commented 2 years ago

Lastly I ran across a typo probablu --> probably

rolandhordos commented 2 years ago

Here's the assertion tripping when restore is running.

assertion-while-debugging
codecov[bot] commented 2 years ago

Codecov Report

Merging #26 (293583b) into master (a974ee5) will decrease coverage by 0.03%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #26      +/-   ##
==========================================
- Coverage   91.66%   91.63%   -0.04%     
==========================================
  Files          30       30              
  Lines        2651     2641      -10     
==========================================
- Hits         2430     2420      -10     
  Misses        221      221              
Impacted Files Coverage Δ
Tests/LittleBlueToothTests/UtilityTest.swift 98.68% <ø> (-0.16%) :arrow_down:
...urces/LittleBlueTooth/Classes/Model/Loggable.swift 100.00% <100.00%> (ø)
Sources/LittleBlueTooth/LittleBlueTooth.swift 82.06% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update a974ee5...293583b. Read the comment docs.

DrAma999 commented 2 years ago

Hello @rolandhordos , really appreciated your PR, thank you so much! Your fix will be released once I had the chance to test code against swift 5.5. Best, Andrea