Feature/example test (#24)

example docs
This commit is contained in:
jeffery
2023-04-12 15:09:44 +08:00
committed by GitHub
parent ac72afe256
commit e9cc195c39
39 changed files with 662 additions and 28 deletions

View 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)
}
})
}
}