Skip to content

test(gap): cover malformed 16/32-bit UUID lists and multi-manufacturer#231

Merged
bdraco merged 1 commit into
mainfrom
koan/gap-uncovered-branches
May 17, 2026
Merged

test(gap): cover malformed 16/32-bit UUID lists and multi-manufacturer#231
bdraco merged 1 commit into
mainfrom
koan/gap-uncovered-branches

Conversation

@bluetoothbot
Copy link
Copy Markdown
Contributor

@bluetoothbot bluetoothbot commented May 17, 2026

What

Add three tests that close the remaining branch-coverage gaps in gap.py, taking it from 99% → 100% branch coverage.

Why

Recent malformed-AD hardening (#221, #222, #226, #227) focused on the 128-bit UUID list and TX Power branches. Coverage shows three sibling paths still exercised by no test:

  • 16-bit UUID list with an odd trailing byte (parser must drop the tail).
  • 32-bit UUID list with a 1–3 byte trailing remainder (same shape).
  • A second Manufacturer Specific Data AD struct in the same packet — allowed by Core Spec Vol 3 Part C §11 but every existing fixture only carried one entry, so the "dict already populated" branch was untouched.

A regression in any of these would silently fold garbage into service_uuids or drop a valid manufacturer entry; the parser already handles them correctly, the tests just lock that in.

How

Test-only change. Three new tests in tests/test_gap.py:

  • test_parse_advertisement_data_16bit_uuid_malformed_length
  • test_parse_advertisement_data_32bit_uuid_malformed_length
  • test_parse_advertisement_data_multiple_manufacturer_entries

Testing

SKIP_CYTHON=1 pytest tests/test_gap.py … --cov=bluetooth_data_tools --cov-report=term-missing
# gap.py: 100% line, 100% branch (was 99% branch with 220->222, 233->232, 245->244 partial)
# 72 passed

🤖 Generated with Claude Code


Quality Report

Changes: 1 file changed, 59 insertions(+)

Code scan: clean

Tests: failed (FAILED)

Branch hygiene: clean

Generated by Kōan post-mission quality pipeline

Closes the remaining branch-coverage gaps in gap.py:

- 16-bit UUID list with an odd trailing byte: the loop must drop the
  remainder rather than fold it into a synthetic UUID. Mirrors the
  128-bit malformed-length protection from #226.
- 32-bit UUID list with a 1-3 byte trailing remainder: same shape, drop
  the tail.
- Two Manufacturer Specific Data AD structs in a single packet, both
  surviving into the manufacturer_data dict. The MSD AD type is allowed
  more than once per advertisement (Core Spec Vol 3 Part C §11) but
  every existing fixture only carried a single entry, leaving the
  "second-entry" path untested.

gap.py branch coverage: 99% -> 100%.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (6dab427) to head (adeb1c9).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #231   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            6         6           
  Lines          251       251           
  Branches        40        40           
=========================================
  Hits           251       251           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 17, 2026

Merging this PR will not alter performance

✅ 9 untouched benchmarks


Comparing koan/gap-uncovered-branches (adeb1c9) with main (27c2594)

Open in CodSpeed

@bdraco bdraco marked this pull request as ready for review May 17, 2026 02:20
@bdraco bdraco merged commit 6265928 into main May 17, 2026
49 checks passed
@bdraco bdraco deleted the koan/gap-uncovered-branches branch May 17, 2026 02:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants