def test_difference(self): elements = ['4', '7', '8', '9', '0'] elements2 = ['4', '5', '6', '10', '8', '9'] elements3 = ['1', '3', '5', '7', '0'] set = HashSet(elements) set2 = HashSet(elements2) set3 = HashSet(elements3) self.assertCountEqual(set.difference(set2).hash.values(), ['7', '0']) # Ignore item order self.assertCountEqual( set.difference(set3).hash.values(), ['4', '8', '9']) # Ignore item order
def test_difference(self): elements = ['5', '6', '8', '10', '1'] elements2 = ['1', '5', '6', '7', '2', '9'] elements3 = ['2', '4', '6', '9', '10'] set1 = HashSet(elements) set2 = HashSet(elements2) set3 = HashSet(elements3) self.assertCountEqual( set1.difference(set2).hash.values(), ['8', '10']) # Item order does not matter self.assertCountEqual( set1.difference(set3).hash.values(), ['5', '8', '1']) # Item order does not matter
def test_difference(self): set_one = HashSet(["A", "B", "C"]) set_two = HashSet(["C", "D", "E"]) set_three = set_one.difference(set_two) assert set_three.size == 4
def test_difference(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.difference(other_set).size == 3 # 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.difference(other_set).size == 4 # 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.difference(other_set).size == 0