Files
gortsplib/pkg/ntp/ntp_test.go
Alessandro Ros 367eb4dffd fix encoding and decoding of NTP fractional part (#869) (#870)
Fractional part now is in 1/(2^32) units, while it was in 1/(1^9) units.
2025-08-31 12:36:17 +02:00

44 lines
682 B
Go

package ntp
import (
"testing"
"time"
"github.com/stretchr/testify/require"
)
var cases = []struct {
name string
dec time.Time
enc uint64
}{
{
"a",
time.Date(2013, 4, 15, 11, 15, 17, 958404853, time.UTC).Local(),
15354565283395798332,
},
{
"b",
time.Date(2013, 4, 15, 11, 15, 18, 0, time.UTC).Local(),
15354565283574448128,
},
}
func TestEncode(t *testing.T) {
for _, ca := range cases {
t.Run(ca.name, func(t *testing.T) {
v := Encode(ca.dec)
require.Equal(t, ca.enc, v)
})
}
}
func TestDecode(t *testing.T) {
for _, ca := range cases {
t.Run(ca.name, func(t *testing.T) {
v := Decode(ca.enc)
require.Equal(t, ca.dec, v)
})
}
}