def test_intersection(self): elements = ['0', 'B', 'C', 'K'] elements2 = ['0', 'D', 'E', 'C', 'Y', 'K'] elements3 = ['B', 'D', 'P', 'K', 'G', '9'] set = HashSet(elements) set2 = HashSet(elements2) set3 = HashSet(elements3) self.assertCountEqual( set.intersection(set2).hash.values(), ['0', 'C', 'K']) # Ignore item order self.assertCountEqual( set.intersection(set3).hash.values(), ['B', 'K']) # Ignore item order
def test_intersection(self): elements = ['2', 'A', 'B', 'C'] elements2 = ['0', 'A', 'C', 'E', 'X', '2'] elements3 = ['B', 'J', 'L', 'K', 'C', '2'] set1 = HashSet(elements) set2 = HashSet(elements2) set3 = HashSet(elements3) self.assertCountEqual( set1.intersection(set2).hash.values(), ['A', 'C', '2']) # Item order does not matter self.assertCountEqual( set1.intersection(set3).hash.values(), ['B', 'C', '2']) # Item order does not matter
def test_intersection(self): set_one = HashSet(["A", "B", "C"]) set_two = HashSet(["C", "D", "E"]) set_three = set_one.intersection(set_two) assert set_three.contains("C") == True assert set_three.size == 1
def test_intersection(self): # two sets with one common element set = HashSet( ['Talent code', 'Outliers', 'Talking to strangers', 'Idea man']) other_set = HashSet( ['Beloved', 'Nightingale', 'Mistress of the game', 'Idea man']) assert set.intersection(other_set).size == 1 # two sets with no common ele set = HashSet( ['Talent code', 'Outliers', 'Talking to strangers', 'Capital']) other_set = HashSet( ['Beloved', 'Nightingale', 'Mistress of the game', 'Idea man']) assert set.intersection(other_set).size == 0 # two sets with the same element set = HashSet( ['Talent code', 'Outliers', 'Talking to strangers', 'Capital']) other_set = HashSet( ['Talent code', 'Outliers', 'Talking to strangers', 'Capital']) assert set.intersection(other_set).size == 4