mirror of
https://github.com/jefferyjob/go-easy-utils.git
synced 2025-09-29 20:32:16 +08:00
24 lines
438 B
Go
24 lines
438 B
Go
package byteUtil
|
|
|
|
import (
|
|
"github.com/stretchr/testify/assert"
|
|
"testing"
|
|
)
|
|
|
|
func TestBytesToStr(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
data []byte
|
|
expected string
|
|
}{
|
|
{"empty slice", []byte{}, ""},
|
|
{"non-empty slice", []byte{'h', 'e', 'l', 'l', 'o'}, "hello"},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
got := BytesToStr(tt.data)
|
|
assert.Equal(t, tt.expected, got)
|
|
})
|
|
}
|
|
}
|