mirror of
https://github.com/jefferyjob/go-easy-utils.git
synced 2025-10-05 06:56:50 +08:00
22
byteUtil/byte_to_str_test.go
Normal file
22
byteUtil/byte_to_str_test.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package byteUtil
|
||||
|
||||
import "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)
|
||||
if got != tt.expected {
|
||||
t.Errorf("BytesToStr(%v) = %v, want %v", tt.data, got, tt.expected)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user