예제 #1
0
 def test_union(self):
     elements = ['A', 'C', 'D', 'F']
     elements2 = ['A', 'B', 'D', 'F', 'G', 'H']
     elements3 = ['C', 'Y', 'T', 'A']
     set = HashSet(elements)
     set2 = HashSet(elements2)
     set3 = HashSet(elements3)
     self.assertCountEqual(
         set.union(set2).hash.values(),
         ['A', 'B', 'C', 'D', 'F', 'G', 'H'])  # Ignore item order
     self.assertCountEqual(
         set.union(set3).hash.values(),
         ['A', 'C', 'D', 'F', 'T', 'Y'])  # Ignore item order
 def test_union(self):
     elements = ['W', 'X', 'Y', 'Z']
     elements2 = ['A', 'B', 'D', 'E', 'G', 'I']
     elements3 = ['C', 'V', 'M', 'N']
     set1 = HashSet(elements)
     set2 = HashSet(elements2)
     set3 = HashSet(elements3)
     self.assertCountEqual(
         set1.union(set2).hash.values(),
         ['A', 'B', 'D', 'E', 'G', 'I', 'W', 'X', 'Y', 'Z'
          ])  # Item order does not matter
     self.assertCountEqual(
         set1.union(set3).hash.values(),
         ['C', 'M', 'N', 'V', 'W', 'X', 'Y', 'Z'
          ])  # Item order does not matter
예제 #3
0
	def test_union(self):

		set_one = HashSet(["A", "B", "C"])
		set_two = HashSet(["C", "D", "E"])

		set_three = set_one.union(set_two)

		assert set_three.size == 5
    def test_union(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.union(other_set).size == 7

        # 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.union(other_set).size == 8

        # 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.union(other_set).size == 4