MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / test_insert

Function test_insert

data_structures/linked_list/skip_list.py:249–266  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

247
248
249def test_insert():
250 skip_list = SkipList()
251 skip_list.insert("Key1", 3)
252 skip_list.insert("Key2", 12)
253 skip_list.insert("Key3", 41)
254 skip_list.insert("Key4", -19)
255
256 node = skip_list.head
257 all_values = {}
258 while node.level != 0:
259 node = node.forward[0]
260 all_values[node.key] = node.value
261
262 assert len(all_values) == 4
263 assert all_values["Key1"] == 3
264 assert all_values["Key2"] == 12
265 assert all_values["Key3"] == 41
266 assert all_values["Key4"] == -19
267
268
269def test_insert_overrides_existing_value():

Callers 1

pytestsFunction · 0.70

Calls 2

insertMethod · 0.95
SkipListClass · 0.85

Tested by

no test coverage detected