Rev 3814: Add tests that we can lookup things after being serialized. in http://bzr.arbash-meinel.com/branches/bzr/brisbane/hash_search_key

John Arbash Meinel john at arbash-meinel.com
Wed Jan 21 20:14:34 GMT 2009


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

------------------------------------------------------------
revno: 3814
revision-id: john at arbash-meinel.com-20090121201426-dorxs36a1djjm6a2
parent: john at arbash-meinel.com-20090121201027-ji143it572y82ou4
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: hash_search_key
timestamp: Wed 2009-01-21 14:14:26 -0600
message:
  Add tests that we can lookup things after being serialized.
-------------- next part --------------
=== modified file 'bzrlib/tests/test_chk_map.py'
--- a/bzrlib/tests/test_chk_map.py	2009-01-21 20:10:27 +0000
+++ b/bzrlib/tests/test_chk_map.py	2009-01-21 20:14:26 +0000
@@ -1082,6 +1082,20 @@
                              "  '7' LeafNode\n"
                              "      ('1',) 'foo'\n"
                              , chkmap._dump_tree())
+        root_key = chkmap._save()
+        chkmap = chk_map.CHKMap(chk_bytes, root_key,
+                                search_key_func=chk_map._search_key_16)
+        # We can get the values back correctly
+        self.assertEqual([(('1',), 'foo')],
+                         list(chkmap.iteritems([('1',)])))
+        self.assertEqualDiff("'' InternalNode\n"
+                             "  '1' LeafNode\n"
+                             "      ('2',) 'bar'\n"
+                             "  '6' LeafNode\n"
+                             "      ('3',) 'baz'\n"
+                             "  '7' LeafNode\n"
+                             "      ('1',) 'foo'\n"
+                             , chkmap._dump_tree())
 
     def test_search_key_255(self):
         chk_bytes = self.get_chk_bytes()
@@ -1099,6 +1113,20 @@
                              "  '\\x83' LeafNode\n"
                              "      ('1',) 'foo'\n"
                              , chkmap._dump_tree())
+        root_key = chkmap._save()
+        chkmap = chk_map.CHKMap(chk_bytes, root_key,
+                                search_key_func=chk_map._search_key_255)
+        # We can get the values back correctly
+        self.assertEqual([(('1',), 'foo')],
+                         list(chkmap.iteritems([('1',)])))
+        self.assertEqualDiff("'' InternalNode\n"
+                             "  '\\x1a' LeafNode\n"
+                             "      ('2',) 'bar'\n"
+                             "  'm' LeafNode\n"
+                             "      ('3',) 'baz'\n"
+                             "  '\\x83' LeafNode\n"
+                             "      ('1',) 'foo'\n"
+                             , chkmap._dump_tree())
 
 
 class TestSearchKeyFuncs(tests.TestCase):



More information about the bazaar-commits mailing list