aboutsummaryrefslogtreecommitdiff
path: root/reader_test.go
diff options
context:
space:
mode:
authorOnur Gündüz <ogunduz@gmail.com>2026-10-08 03:13:23 +0200
committerOnur Gündüz <ogunduz@gmail.com>2026-10-08 03:13:23 +0200
commitd0aa2923afcb73a721d6ea135809d1d6ece250ad (patch)
treebe32cfcfca46004d0c0bdb55de3c3d01bfffdb98 /reader_test.go
parent7299813c0e16d20f579e2511e9a7c2ecfc3eddc9 (diff)
downloadmuxer-d0aa2923afcb73a721d6ea135809d1d6ece250ad.tar.gz
muxer-d0aa2923afcb73a721d6ea135809d1d6ece250ad.zip
Apply go fix
Diffstat (limited to 'reader_test.go')
-rw-r--r--reader_test.go27
1 files changed, 12 insertions, 15 deletions
diff --git a/reader_test.go b/reader_test.go
index e9ff373..ab00b36 100644
--- a/reader_test.go
+++ b/reader_test.go
@@ -18,7 +18,7 @@ import (
type testCase struct {
desc string
reads [][]byte
- expect []interface{}
+ expect []any
size int
}
@@ -26,9 +26,8 @@ var maxID = uint64(math.Pow(2, 60)) - 1
func TestReadMessage(t *testing.T) {
// Run test cases in normal and reversed order.
- test := func(prefix string, messages []interface{}, bytes [][]byte, bufferSize int) {
+ test := func(prefix string, messages []any, bytes [][]byte, bufferSize int) {
for _, tt := range makeTestCases(prefix, bufferSize, messages, bytes, io.EOF) {
- tt := tt
t.Run(tt.desc, func(t *testing.T) {
runTest(t, tt)
})
@@ -42,7 +41,6 @@ func TestReadMessage(t *testing.T) {
}
for _, tt := range makeTestCases(prefix, bufferSize, messages, bytes, io.EOF) {
- tt := tt
t.Run(tt.desc, func(t *testing.T) {
runTest(t, tt)
})
@@ -51,7 +49,7 @@ func TestReadMessage(t *testing.T) {
// Send headers only.
func() {
- var messages []interface{}
+ var messages []any
var bytes [][]byte
bufferSize := 16
@@ -68,7 +66,7 @@ func TestReadMessage(t *testing.T) {
// Messages that fill up the entire buffer.
func() {
- var messages []interface{}
+ var messages []any
var bytes [][]byte
bufferSize := 16
@@ -86,7 +84,7 @@ func TestReadMessage(t *testing.T) {
// Messages with smaller payloads.
func() {
- var messages []interface{}
+ var messages []any
var bytes [][]byte
bufferSize := 16
@@ -140,7 +138,7 @@ func TestReadMessage(t *testing.T) {
reads: func() [][]byte {
payload := newBytes(0, 0, 2, 0, 0)
var xs [][]byte
- for i := 0; i < len(payload); i++ {
+ for i := range payload {
xs = append(xs, payload[i:i+1])
}
return reading(xs...)
@@ -239,7 +237,7 @@ func TestReadMessage(t *testing.T) {
},
{
desc: "receive two with small buffer",
- expect: func() []interface{} {
+ expect: func() []any {
return expecting(
newMessage(0, 1, 2),
io.ErrShortBuffer,
@@ -255,7 +253,7 @@ func TestReadMessage(t *testing.T) {
},
{
desc: "receive two chunked with small buffer",
- expect: func() []interface{} {
+ expect: func() []any {
return expecting(
newMessage(0, 1, 2),
io.ErrShortBuffer,
@@ -377,7 +375,7 @@ func TestReadMessage(t *testing.T) {
),
reads: func() [][]byte {
xs := chunksOf(newBytes(5, 10, 2, 0, 0), 2)
- for i := 0; i < 100; i++ {
+ for range 100 {
xs = append(xs, make([]byte, 0))
}
return xs
@@ -403,7 +401,6 @@ func TestReadMessage(t *testing.T) {
}
start := 0
for _, tt := range testCases[start:] {
- tt := tt
t.Run(tt.desc, func(t *testing.T) {
runTest(t, tt)
})
@@ -448,7 +445,7 @@ func newBytes(id uint64, ch uint8, l int, start, end int) []byte {
func fill(times int) string {
var s strings.Builder
chars := "abcdefghijklmnopqrstuvwxyz"
- for i := 0; i < times; i++ {
+ for i := range times {
pos := i % len(chars)
s.WriteString(chars[pos : pos+1])
}
@@ -482,7 +479,7 @@ func runTest(t *testing.T, tt testCase) {
}
}
-func makeTestCases(prefix string, bufferSize int, messages []interface{}, bytes [][]byte, expectedErr error) (testCases []testCase) {
+func makeTestCases(prefix string, bufferSize int, messages []any, bytes [][]byte, expectedErr error) (testCases []testCase) {
for i := range messages {
testCases = append(testCases, testCase{
desc: fmt.Sprintf("%s single read %d", prefix, i),
@@ -578,7 +575,7 @@ func reading(xs ...[]byte) [][]byte {
return xs
}
-func expecting(xs ...interface{}) []interface{} {
+func expecting(xs ...any) []any {
return xs
}