Skip to content

Commit c870d62

Browse files
tanghaowillowstv0g
authored andcommittedAug 8, 2023
Test: port old fuzzing code to go-fuzzing
1 parent 3975f0d commit c870d62

File tree

2 files changed

+20
-34
lines changed

2 files changed

+20
-34
lines changed
 

‎fuzz.go

-34
This file was deleted.

‎fuzz_test.go

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package sdp
2+
3+
import "testing"
4+
5+
func FuzzUnmarshal(f *testing.F) {
6+
f.Add([]byte{})
7+
f.Add([]byte(CanonicalMarshalSDP))
8+
f.Fuzz(func(t *testing.T, data []byte) {
9+
// Check that unmarshalling any byte slice does not panic.
10+
var sd SessionDescription
11+
if err := sd.Unmarshal(data); err != nil {
12+
return
13+
}
14+
// Check that we can marshal anything we unmarshalled.
15+
_, err := sd.Marshal()
16+
if err != nil {
17+
t.Fatalf("failed to marshal")
18+
}
19+
})
20+
}

0 commit comments

Comments
 (0)
Please sign in to comment.