John Carr hace 16 años
padre
commit
2df5ce471b
Se han modificado 1 ficheros con 22 adiciones y 0 borrados
  1. 22 0
      dulwich/tests/test_pack.py

+ 22 - 0
dulwich/tests/test_pack.py

@@ -32,6 +32,8 @@ from dulwich.pack import (
         write_pack_index_v1,
         write_pack_index_v2,
         write_pack,
+        apply_delta,
+        create_delta,
         )
 
 pack1_sha = 'bc63ddad95e7321ee734ea11a7a62d314e0d7481'
@@ -91,6 +93,26 @@ class PackIndexTests(PackTests):
     self.assertEquals(set([tree_sha, commit_sha, a_sha]), set(p))
 
 
+class TestPackDeltas(unittest.TestCase):
+
+  test_string1 = "The answer was flailing in the wind"
+  test_string2 = "The answer was falling down the pipe"
+  test_string3 = "zzzzz"
+
+  def _test_roundtrip(self, base, target):
+    self.assertEquals(target,
+      apply_delta(base, create_delta(base, target)))
+
+  def test_nochange(self):
+    self._test_roundtrip(self.test_string1, self.test_string1)
+
+  def test_change(self):
+    self._test_roundtrip(self.test_string1, self.test_string2)
+
+  def test_rewrite(self):
+    self._test_roundtrip(self.test_string1, self.test_string3)
+
+
 class TestPackData(PackTests):
   """Tests getting the data from the packfile."""