Skip to content

Commit

Permalink
Add test for zero values
Browse files Browse the repository at this point in the history
Resolves #11
  • Loading branch information
Sean-Der committed Mar 28, 2024
1 parent b293b8f commit 2edc074
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
3 changes: 0 additions & 3 deletions marshal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,6 @@ func TestMarshalCanonical(t *testing.T) {
}
}

// var sink []byte

func BenchmarkMarshal(b *testing.B) {
b.ReportAllocs()
var sd SessionDescription
Expand All @@ -182,7 +180,6 @@ func BenchmarkMarshal(b *testing.B) {
b.Fatal(err)
}
for i := 0; i < b.N; i++ {
// sink, err = sd.Marshal()
_, err = sd.Marshal()
if err != nil {
b.Fatal(err)
Expand Down
15 changes: 15 additions & 0 deletions unmarshal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"errors"
"strconv"
"testing"

"github.com/stretchr/testify/require"
)

const (
Expand Down Expand Up @@ -376,6 +378,19 @@ func TestUnmarshalNonNilAddress(t *testing.T) {
}
}

func TestUnmarshalZeroValues(t *testing.T) {
in := "v=0\r\no=0 0 0 IN IP4 0\r\ns=\r\nt=0 0\r\n"
var sd SessionDescription
require.NoError(t, sd.UnmarshalString(in))

out, err := sd.Marshal()
if err != nil {
require.NoError(t, err)
}

require.Equal(t, in, string(out))
}

func BenchmarkUnmarshal(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
Expand Down

0 comments on commit 2edc074

Please sign in to comment.