def test_union(self): s1 = Sets(['A', 'B', 'C']) s2 = Sets(['D', 'E']) union_set = s1.union(s2) self.assertCountEqual(union_set.set_struct.keys(), ['A', 'B', 'C', 'D', 'E']) s1 = Sets(['A', 'A', 'B', 'C']) s2 = Sets(['E', 'F', 'G']) union_set = s1.union(s2) assert (union_set.set_struct.size == 7) == False
def test_union(self): set_A = Sets() set_B = Sets() set_A.add('Medi') set_A.add('Mace') set_B.add('Yves') set_B.add('Sarin') assert type(set_A.union(set_B)) == list # should return a list assert set_A.size == 2 # set A should retain its original size assert set_B.size == 2 # set B should retain its original size union_result = set_A.union(set_B) assert len( union_result ) == 4 # the result of the union should have a size of set A+B
def test_union(self): first_set = Sets([1, 2, 3, 4]) second_set = Sets([1, 2, 3]) union_set = second_set.union(first_set) assert union_set.size == 4 assert union_set.contains(1) == True assert union_set.contains(2) == True assert union_set.contains(3) == True assert union_set.contains(4) == True