def test_difference(self): set1 = PersistentBalancedSet(5, iterator='preorder').insert(6).insert(7) set2 = PersistentBalancedSet(3).insert(2).insert(1) set3 = PersistentBalancedSet(5) balancedSet = set1.difference(set2) balancedSet1 = set1.difference(set3) self.assertEqual(set1, [6, 5, 7]) self.assertEqual(set2, [1, 2, 3]) self.assertEqual(balancedSet, [6, 5, 7]) self.assertEqual(balancedSet1, [6, 7])
def test_difference2(self): set1 = PersistentBalancedSet(5, iterator='preorder').insert(6).insert(7) set2 = PersistentBalancedSet(5, iterator='preorder').insert(6) balancedSet = set1.difference(set2) self.assertEqual(set1, [6, 5, 7]) self.assertEqual(set2, [5, 6]) self.assertEqual(balancedSet, [7])
def test_difference3(self): set1 = PersistentBalancedSet(5, iterator='preorder').insert(6).insert( 7).insert(4).insert(2).insert(1) set2 = PersistentBalancedSet(57, iterator='preorder').insert( 36).insert(67).insert(24).insert(72).insert(4) balancedSet = set1.difference(set2) self.assertEqual(set1, [4, 2, 1, 6, 5, 7]) self.assertEqual(set2, [57, 24, 4, 36, 67, 72]) self.assertEqual(balancedSet, [2, 1, 6, 5, 7])