def test(): m = TreeMap(none_low) m.put('a', 'A') m.put('b', 'B') m.put('c', 'C') assert m.to_string() == '{a=A, b=B, c=C}' assert m.head_map('b').to_string() == '{a=A}' assert m.tail_map('b').to_string() == '{b=B, c=C}' assert m.head_map(None).to_string() == '{}' assert m.tail_map(None).to_string() == '{a=A, b=B, c=C}' m = TreeMap(none_high) m.put('a', 'A') m.put('b', 'B') m.put('c', 'C') assert m.to_string() == '{a=A, b=B, c=C}' assert m.head_map('b').to_string() == '{a=A}' assert m.tail_map('b').to_string() == '{b=B, c=C}' assert m.head_map(None).to_string() == '{a=A, b=B, c=C}' assert m.tail_map(None).to_string() == '{}' m.put(None, 'NONE') assert m.to_string() == '{a=A, b=B, c=C, None=NONE}' assert m.head_map('b').to_string() == '{a=A}' assert m.tail_map('b').to_string() == '{b=B, c=C, None=NONE}' assert m.head_map(None).to_string() == '{a=A, b=B, c=C}' assert m.tail_map(None).to_string() == '{None=NONE}'
def test_main(self): m = TreeMap() self.test_navigable_map_removers(m) self.test_navigable_map(m) self.test_navigable_map(m.head_map(6, False)) self.test_navigable_map(m.head_map(5, True)) self.test_navigable_map(m.tail_map(0, False)) self.test_navigable_map(m.tail_map(1, True)) self.test_navigable_map(m.sub_map(1, 6, True, False)) self.test_navigable_map(m.sub_map(0, 5, False, True)) self.check_functional_invariants(m) m.clear() assert m.put(3333, 77777) is None assert m.put(9134, 74982) is None assert m.get(9134) == 74982 assert m.put(9134, 1382) == 74982 assert m.get(9134) == 1382 assert m.size() == 2 self.check_functional_invariants(m)
def test(): m1 = TreeMap(none_at_end) assert m1.put('a', 'a') is None assert m1.put('b', 'b') is None assert m1.put('c', 'c') is None assert m1.put(None, 'd') is None m2 = TreeMap(none_at_end) m2.put_all(m1) assert m1.last_key() is None assert m1.get(m1.last_key()) == 'd' assert m1.remove(m1.last_key()) == 'd' assert m1.last_key() == 'c' assert m2.entry_set().to_string() == '[a=a, b=b, c=c, None=d]' m3 = m2.tail_map('b') assert m3.last_key() is None assert m3.get(m3.last_key()) == 'd' assert m3.remove(m3.last_key()) == 'd' assert m3.last_key() == 'c'