File: fuzz_test.go

package info (click to toggle)
golang-github-pion-sdp 3.0.10-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental, sid, trixie
  • size: 304 kB
  • sloc: makefile: 2
file content (23 lines) | stat: -rw-r--r-- 548 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
// SPDX-License-Identifier: MIT

package sdp

import "testing"

func FuzzUnmarshal(f *testing.F) {
	f.Add("")
	f.Add(CanonicalUnmarshalSDP)
	f.Fuzz(func(t *testing.T, data string) {
		// Check that unmarshalling any byte slice does not panic.
		var sd SessionDescription
		if err := sd.UnmarshalString(data); err != nil {
			return
		}
		// Check that we can marshal anything we unmarshalled.
		_, err := sd.Marshal()
		if err != nil {
			t.Fatalf("failed to marshal")
		}
	})
}