def test_memory_dict_get(): memory = MemoryDict({14: 15}) assert memory.get(14, 'default') == 15 assert memory.get(1234, 'default') == 'default' assert memory.get(-10, 'default') == 'default' # Attempting to read address with a negative offset is ok, it simply returns None. assert memory.get(RelocatableValue(segment_index=10, offset=-2)) is None
def test_memory_dict_get(): md = MemoryDict({14: 15}) assert md.get(14, 'default') == 15 assert md.get(1234, 'default') == 'default' with pytest.raises(ValueError, match='must be nonnegative'): md.get(-10, 'default') # Attempting to read address with a negative offset is ok, it simply returns None. assert md.get(RelocatableValue(segment_index=10, offset=-2)) is None
def test_memory_dict_get(): md = MemoryDict({14: 15}) assert md.get(14, 'default') == 15 assert md.get(1234, 'default') == 'default' with pytest.raises(ValueError, match='must be positive'): md.get(-10, 'default')