def test_intersection(self):
     elements = ['0', 'B', 'C', 'K']
     elements2 = ['0', 'D', 'E', 'C', 'Y', 'K']
     elements3 = ['B', 'D', 'P', 'K', 'G', '9']
     set = TreeSet(elements)
     set2 = TreeSet(elements2)
     set3 = TreeSet(elements3)
     self.assertCountEqual(
         set.intersection(set2).tree.items_in_order(),
         ['0', 'C', 'K'])  # Ignore item order
     self.assertCountEqual(
         set.intersection(set3).tree.items_in_order(),
         ['B', 'K'])  # Ignore item order
Example #2
0
 def test_intersection(self):
     """Testing the intersection method"""
     set_one = TreeSet(['C', 'B', 'A', 'E', 'D'])
     set_two = TreeSet(['G', 'F', 'E', 'I', 'H'])
     intersection = set_one.intersection(set_two)
     assert not intersection.contains('A')
     assert not intersection.contains('C')
     assert intersection.contains('E')
     assert not intersection.contains('G')
     assert not intersection.contains('I')
     assert intersection.size == 1