Beispiel #1
0
 def test_rank_negative():
     """A test to check that rank finds index of a key in sorted order."""
     keys = list(range(-100, 100))
     d = OrderedTreeDict((key, None) for key in keys)
     assert all(list(keys[d.rank(k)] == k for k in keys))
Beispiel #2
0
 def test_rank_simple():
     d = OrderedTreeDict([(0, 0), (1, 1), (2, 2)])
     assert len(d) == 3
     assert (d.rank(0) == 0)
     assert (d.rank(1) == 1)
     assert (d.rank(2) == 2)