MCPcopy Create free account
hub / github.com/ActiveState/code / test_tree

Function test_tree

recipes/Python/576817_Red_black_tree/recipe-576817.py:273–282  ·  view source on GitHub ↗

Insert keys one by one checking invariants and membership as we go.

(t, keys)

Source from the content-addressed store, hash-verified

271
272
273def test_tree(t, keys):
274 "Insert keys one by one checking invariants and membership as we go."
275 assert t.check_invariants()
276 for i, key in enumerate(keys):
277 for key2 in keys[:i]:
278 assert t.nil != t.search(key2)
279 for key2 in keys[i:]:
280 assert (t.nil == t.search(key2)) ^ (key2 in keys[:i])
281 t.insert_key(key)
282 assert t.check_invariants()
283
284
285if '__main__' == __name__:

Callers 1

recipe-576817.pyFile · 0.85

Calls 4

insert_keyMethod · 0.80
enumerateFunction · 0.50
check_invariantsMethod · 0.45
searchMethod · 0.45

Tested by

no test coverage detected