Beispiel #1
0
 def test_remove(self):
     new_set = HashSet(['red', 'brown', 'gray'])
     assert new_set.__length__() == 3
     new_set.remove('brown')
     assert new_set.__length__() == 2
     assert new_set.contains('brown') == False
     assert new_set.contains('red') == True
     assert new_set.contains('gray') == True
     new_set.remove('gray')
     assert new_set.__length__() == 1
     assert new_set.contains('red') == True
     assert new_set.contains('gray') == False
Beispiel #2
0
 def test_add(self):
     new_set = HashSet()
     assert new_set.__length__() == 0
     new_set.add('red')
     new_set.add('brown')
     new_set.add('gray')
     assert new_set.__length__() == 3
     assert new_set.contains('red') == True
     assert new_set.contains('brown') == True
     assert new_set.contains('purple') == False
     new_set.add('orange')
     new_set.add('purple')
     assert new_set.__length__() == 5
     assert new_set.contains('purple') == True
Beispiel #3
0
 def test_init(self):
     new_set = HashSet()
     assert new_set.size == 0
     working_set = HashSet(['Working', 'Set'])
     assert working_set.__length__() == 2