def test_union(self): elements = ['A', 'C', 'D', 'F'] elements2 = ['A', 'B', 'D', 'F', 'G', 'H'] elements3 = ['C', 'Y', 'T', 'A'] set = TreeSet(elements) set2 = TreeSet(elements2) set3 = TreeSet(elements3) self.assertCountEqual( set.union(set2).tree.items_in_order(), ['A', 'B', 'C', 'D', 'F', 'G', 'H']) # Ignore item order self.assertCountEqual( set.union(set3).tree.items_in_order(), ['A', 'C', 'D', 'F', 'T', 'Y']) # Ignore item order
def test_union(self): s1 = TreeSet([1, 2, 3, 4]) s2 = TreeSet([4, 2, 5, 1]) union_set = s1.union(s2) assert union_set.contains(1) is True assert union_set.contains(2) is True assert union_set.contains(4) is True assert union_set.contains(3) is True assert union_set.contains(5) is True assert union_set.contains(6) is False
def test_union(self): """Testing the union method""" set_one = TreeSet(['C', 'B', 'A', 'E', 'D']) set_two = TreeSet(['G', 'F', 'E', 'I', 'H']) union = set_one.union(set_two) assert repr(union) == "('A'), ('B'), ('C'), ('D'), ('E'), \ ('F'), ('G'), ('H'), ('I')" assert union.contains('A') assert union.contains('C') assert union.contains('E') assert union.contains('G') assert union.contains('I') assert union.size == 9