Rev 3795: Add a test that unmap() properly chains back up multiple levels. in http://bzr.arbash-meinel.com/branches/bzr/brisbane/chk_map

John Arbash Meinel john at arbash-meinel.com
Tue Dec 2 18:45:04 GMT 2008


At http://bzr.arbash-meinel.com/branches/bzr/brisbane/chk_map

------------------------------------------------------------
revno: 3795
revision-id: john at arbash-meinel.com-20081202184452-830u3t32hjagsk1y
parent: john at arbash-meinel.com-20081202183902-pzwr8vxzdubumrjy
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: chk_map
timestamp: Tue 2008-12-02 12:44:52 -0600
message:
  Add a test that unmap() properly chains back up multiple levels.
-------------- next part --------------
=== modified file 'bzrlib/tests/test_chk_map.py'
--- a/bzrlib/tests/test_chk_map.py	2008-12-02 18:39:02 +0000
+++ b/bzrlib/tests/test_chk_map.py	2008-12-02 18:44:52 +0000
@@ -358,6 +358,31 @@
                              chkmap._dump_tree())
         self.assertCanonicalForm(chkmap)
 
+    def test_stable_unmap_double_deep(self):
+        store = self.get_chk_bytes()
+        chkmap = CHKMap(store, None)
+        # Should fit 2 keys per LeafNode
+        chkmap._root_node.set_maximum_size(30)
+        chkmap.map(('aaa',), 'v')
+        chkmap.map(('aab',), 'very long value')
+        chkmap.map(('abc',), 'v')
+        self.assertEqualDiff("'' InternalNode None\n"
+                             "  'aa' InternalNode None\n"
+                             "    'aaa' LeafNode None\n"
+                             "      ('aaa',) 'v'\n"
+                             "    'aab' LeafNode None\n"
+                             "      ('aab',) 'very long value'\n"
+                             "  'ab' LeafNode None\n"
+                             "      ('abc',) 'v'",
+                             chkmap._dump_tree())
+        # Removing the 'aab' key should cause everything to collapse back to a
+        # single node
+        chkmap.unmap(('aab',))
+        self.assertEqualDiff("'' LeafNode None\n"
+                             "      ('aaa',) 'v'\n"
+                             "      ('abc',) 'v'",
+                             chkmap._dump_tree())
+
     def test_iter_changes_empty_ab(self):
         # Asking for changes between an empty dict to a dict with keys returns
         # all the keys.



More information about the bazaar-commits mailing list