feat(transcode): add a generic transcoding package for encoding/decoding/caching
This commit is contained in:
30
server/ctrlsubsonic/httprange/httprange_test.go
Normal file
30
server/ctrlsubsonic/httprange/httprange_test.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package httprange_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/matryer/is"
|
||||
"go.senan.xyz/gonic/server/ctrlsubsonic/httprange"
|
||||
)
|
||||
|
||||
func TestParse(t *testing.T) {
|
||||
is := is.New(t)
|
||||
|
||||
full := func(start, end, length int) httprange.Range {
|
||||
return httprange.Range{Start: start, End: end, Length: length}
|
||||
}
|
||||
partial := func(start, end, length int) httprange.Range {
|
||||
return httprange.Range{Start: start, End: end, Length: length, Partial: true}
|
||||
}
|
||||
parse := func(in string, length int) httprange.Range {
|
||||
is.Helper()
|
||||
rrange, err := httprange.Parse(in, length)
|
||||
is.NoErr(err)
|
||||
return rrange
|
||||
}
|
||||
|
||||
is.Equal(parse("bytes=0-0", 0), full(0, 0, 0))
|
||||
is.Equal(parse("bytes=0-", 10), full(0, 9, 10))
|
||||
is.Equal(parse("bytes=0-49", 50), partial(0, 49, 50))
|
||||
is.Equal(parse("bytes=50-99", 100), partial(50, 99, 50))
|
||||
}
|
||||
Reference in New Issue
Block a user