/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/tests/test__simple_set.py

  • Committer: Jelmer Vernooij
  • Date: 2018-02-18 21:42:57 UTC
  • mto: This revision was merged to the branch mainline in revision 6859.
  • Revision ID: jelmer@jelmer.uk-20180218214257-jpevutp1wa30tz3v
Update TODO to reference Breezy, not Bazaar.

Show diffs side-by-side

added added

removed removed

Lines of Context:
83
83
# Even though this is an extension, we don't permute the tests for a python
84
84
# version. As the plain python version is just a dict or set
85
85
compiled_simpleset_feature = features.ModuleAvailableFeature(
86
 
    'breezy._simple_set_pyx')
 
86
                                'breezy._simple_set_pyx')
87
87
 
88
88
 
89
89
class TestSimpleSet(tests.TestCase):
107
107
        # I'm not sure why the offset is 3, but I've check that in the caller,
108
108
        # an offset of 1 works, which is expected. Not sure why assertRefcount
109
109
        # is incrementing/decrementing 2 times
110
 
        self.assertEqual(count, sys.getrefcount(obj) - 3)
 
110
        self.assertEqual(count, sys.getrefcount(obj)-3)
111
111
 
112
112
    def test_initial(self):
113
113
        obj = self.module.SimpleSet()
114
114
        self.assertEqual(0, len(obj))
 
115
        st = ('foo', 'bar')
115
116
        self.assertFillState(0, 0, 0x3ff, obj)
116
117
 
117
118
    def test__lookup(self):
120
121
        obj = self.module.SimpleSet()
121
122
        self.assertLookup(643, '<null>', obj, _Hashable(643))
122
123
        self.assertLookup(643, '<null>', obj, _Hashable(643 + 1024))
123
 
        self.assertLookup(643, '<null>', obj, _Hashable(643 + 50 * 1024))
 
124
        self.assertLookup(643, '<null>', obj, _Hashable(643 + 50*1024))
124
125
 
125
126
    def test__lookup_collision(self):
126
127
        obj = self.module.SimpleSet()
140
141
        obj.add(k2)
141
142
        self.assertLookup(643, k1, obj, k1)
142
143
        self.assertLookup(644, k2, obj, k2)
143
 
        obj._py_resize(2047)  # resized to 2048
 
144
        obj._py_resize(2047) # resized to 2048
144
145
        self.assertEqual(2048, obj.mask + 1)
145
146
        self.assertLookup(643, k1, obj, k1)
146
 
        self.assertLookup(643 + 1024, k2, obj, k2)
147
 
        obj._py_resize(1023)  # resized back to 1024
 
147
        self.assertLookup(643+1024, k2, obj, k2)
 
148
        obj._py_resize(1023) # resized back to 1024
148
149
        self.assertEqual(1024, obj.mask + 1)
149
150
        self.assertLookup(643, k1, obj, k1)
150
151
        self.assertLookup(644, k2, obj, k2)
154
155
 
155
156
        h1 = 643
156
157
        h2 = 643 + 1024
157
 
        h3 = 643 + 1024 * 50
158
 
        h4 = 643 + 1024 * 25
 
158
        h3 = 643 + 1024*50
 
159
        h4 = 643 + 1024*25
159
160
        h5 = 644
160
161
        h6 = 644 + 1024
161
162
 
236
237
        # doesn't add anything, so the counters shouldn't be adjusted
237
238
        self.assertIs(k1, obj.add(k2))
238
239
        self.assertFillState(1, 1, 0x3ff, obj)
239
 
        self.assertRefcount(2, k1)  # not changed
240
 
        self.assertRefcount(1, k2)  # not incremented
 
240
        self.assertRefcount(2, k1) # not changed
 
241
        self.assertRefcount(1, k2) # not incremented
241
242
        self.assertIs(k1, obj[k1])
242
243
        self.assertIs(k1, obj[k2])
243
244
        self.assertRefcount(2, k1)
338
339
 
339
340
    def test_add_and_remove_lots_of_items(self):
340
341
        obj = self.module.SimpleSet()
341
 
        chars = ('ABCDEFGHIJKLMNOPQRSTUVWXYZ'
342
 
                 'abcdefghijklmnopqrstuvwxyz1234567890')
 
342
        chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890'
343
343
        for i in chars:
344
344
            for j in chars:
345
345
                k = (i, j)
346
346
                obj.add(k)
347
 
        num = len(chars) * len(chars)
 
347
        num = len(chars)*len(chars)
348
348
        self.assertFillState(num, num, 0x1fff, obj)
349
349
        # Now delete all of the entries and it should shrink again
350
350
        for i in chars: