-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfuzz_test.go
More file actions
41 lines (35 loc) · 774 Bytes
/
fuzz_test.go
File metadata and controls
41 lines (35 loc) · 774 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2025 TotallyGamerJet
package bsdiff
import (
"bytes"
"testing"
)
func Fuzz_offt(f *testing.F) {
f.Add(9001)
f.Add(-9001)
f.Fuzz(func(t *testing.T, x int) {
buf := make([]byte, 8)
offtout(x, buf)
y := offtin(buf)
if x != y {
t.Errorf("x != y: %d != %d", x, y)
}
})
}
func FuzzDiffPatch(f *testing.F) {
f.Add([]byte("Here is text"), []byte("Here are some texts that I have"))
f.Fuzz(func(t *testing.T, old, new []byte) {
patch, err := Diff(old, new)
if err != nil {
t.Errorf("diff failed: %s", err)
}
new2, err := Patch(old, patch)
if err != nil {
t.Errorf("patch failed: %s", err)
}
if !bytes.Equal(new, new2) {
t.Errorf("patch did not recreate the file")
}
})
}