Exemple #1
0
 def test_contains(self):
     new_set = HashSet(['This', 'is', 'my', 'set'])
     assert new_set.contains('This') == True
     assert new_set.contains('my') == True
     assert new_set.contains('set') == True
     assert new_set.contains('Willowwww') == False
     assert new_set.contains('your') == False
Exemple #2
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
Exemple #3
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