def test_get_section_raises(join): img = Image(join=join) img.insert_section(data=range(10), start_address=0x030) img.insert_section(data=range(10), start_address=0x020) img.insert_section(data=range(10), start_address=0x010) img.insert_section(data=range(10), start_address=0x000) with pytest.raises(InvalidAddressError): sec = img.get_section(0x3a) with pytest.raises(InvalidAddressError): sec = img.get_section(0x2b) with pytest.raises(InvalidAddressError): sec = img.get_section(0x1c) with pytest.raises(InvalidAddressError): sec = img.get_section(0x0d)
def test_get_section1(): img = Image(join=False) img.insert_section(data=range(16), start_address=0x030) img.insert_section(data=range(16), start_address=0x020) img.insert_section(data=range(16), start_address=0x010) img.insert_section(data=range(16), start_address=0x000) sec = img.get_section(0x33) assert sec.start_address == 0x30 sec = img.get_section(0x22) assert sec.start_address == 0x20 sec = img.get_section(0x11) assert sec.start_address == 0x10 sec = img.get_section(0x02) assert sec.start_address == 0x00
def test_get_section2(): img = Image(join=True) img.insert_section(data=range(16), start_address=0x030) img.insert_section(data=range(16), start_address=0x020) img.insert_section(data=range(16), start_address=0x010) img.insert_section(data=range(16), start_address=0x000) sec = img.get_section(0x33) assert sec.start_address == 0x00 assert len(sec) == 64