Use the iterator design for bytes based API as well

This commit is contained in:
Kovid Goyal
2023-07-04 22:33:14 +05:30
parent e7d02b79d7
commit 83d97c515c
2 changed files with 26 additions and 10 deletions

View File

@@ -81,8 +81,16 @@ func run_roundtrip_test(t *testing.T, src_data, changed []byte, num_of_patches,
t.Fatal(err)
}
deltabuf := bytes.Buffer{}
if err := d.CreateDelta(bytes.NewReader(src_data), func(b []byte) error { _, err := deltabuf.Write(b); return err }); err != nil {
t.Fatal(err)
it := d.CreateDelta(bytes.NewBuffer(src_data))
for {
b, err := it()
if b == nil {
if err != nil {
t.Fatal(err)
}
break
}
deltabuf.Write(b)
}
outputbuf := bytes.Buffer{}
p.StartDelta(&outputbuf, bytes.NewReader(src_data))