예제 #1
0
 def test_add(self):
     list_set = ArraySet()
     list_set.add(3)
     assert list_set.size is 1
     list_set.add(2)
     assert list_set.size is 2
     list_set.add(2)
     assert list_set.size is 2
예제 #2
0
 def test_intersection(self):
     set_one = ArraySet(["apple", "fruit", "pear"])
     set_two = ArraySet(["apple", "fruit", "pear", "orange"])
     new_set = set_one.intersection(set_two)
     assert new_set.elements == ["apple", "fruit", "pear"]
     set_one = ArraySet([1, 2, 3, 4])
     set_two = ArraySet([2, 31, 2, 31, 2, 1, 2, 3, 4])
     new_set = set_one.intersection(set_two)
     assert new_set.elements == [2, 1, 3, 4]
예제 #3
0
 def test_size(self):
     list_set = ArraySet()
     assert list_set.size is 0
     list_set.add(1)
     assert list_set.size is 1
     list_set.add(2)
     assert list_set.size is 2
     list_set.add(3)
     assert list_set.size is 3
예제 #4
0
    def test_is_sub_set(self):
        set_one = ArraySet(["apple", "fruit", "pear"])
        set_two = ArraySet(["apple", "fruit", "pear", "orange"])
        is_subset = set_one.is_sub_set(set_two)
        assert is_subset is True

        set_one = ArraySet(["watermelon", "apple", "pear"])
        set_two = ArraySet(["pear", "grape", "orange"])

        is_subset = set_one.is_sub_set(set_two)
        assert is_subset is False
예제 #5
0
    def test_difference(self):

        set_one = ArraySet(["apple", "fruit", "pear"])
        set_two = ArraySet(["apple", "fruit", "pear", "orange"])
        new_set = set_one.difference(set_two)
        assert new_set.elements == ["orange"]

        set_one = ArraySet([1, 2, 3, 4])
        set_two = ArraySet([2, 31, 2, 31, 2, 1, 2, 3, 4])
        new_set = set_one.difference(set_two)
        assert new_set.elements == [31]
예제 #6
0
 def test_init_with_list(self):
     list_set = ArraySet([1, 2, 3])
     assert list_set.size is 3
     assert list_set.contains(2)
예제 #7
0
 def test_init(self):
     list_set = ArraySet()
     assert list_set.size is 0
예제 #8
0
 def test_union(self):
     set_one = ArraySet([1, 2, 3, 4])
     assert set_one.size is 4
     set_two = ArraySet([1, 2, 3, 4, 5, 4, 5, 3, 5, 6, 7])
     set_one.union(set_two)
     assert set_one.size is 7
예제 #9
0
 def test_remove(self):
     list_set = ArraySet([1, 2, 3])
     assert list_set.size is 3
     list_set.remove(2)
     assert list_set.size is 2