Skip to content

Commit 6fdba53

Browse files
bluetoothbotclaude
andauthored
test(gap): cover local-name precedence between SHORT and COMPLETE (#278)
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 35d82c9 commit 6fdba53

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

tests/test_gap.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,28 @@ def test_parse_advertisement_short_local_name():
219219
assert adv.tx_power is None
220220

221221

222+
def test_parse_advertisement_complete_overrides_short_local_name():
223+
# SHORT (0x08) appears first then COMPLETE (0x09) follows; COMPLETE must
224+
# overwrite the short form so callers always see the longer name when
225+
# both are present.
226+
data = [b"\x04\x08Bar\x04\x09Foo"]
227+
228+
adv = parse_advertisement_data(data)
229+
230+
assert adv.local_name == "Foo"
231+
232+
233+
def test_parse_advertisement_short_local_name_ignored_after_complete():
234+
# COMPLETE (0x09) appears first then SHORT (0x08) follows; the SHORT
235+
# branch is gated on ``local_name is None``, so the previously-set
236+
# complete name must survive.
237+
data = [b"\x04\x09Foo\x04\x08Bar"]
238+
239+
adv = parse_advertisement_data(data)
240+
241+
assert adv.local_name == "Foo"
242+
243+
222244
def test_parse_advertisement_data_32bit_service_data():
223245
data = [
224246
b"\x07\x20\x1a\x02\n\x05\n\xff",

0 commit comments

Comments
 (0)