shad-go/illegal/string_test.go
Fedor Korotkiy f513f744b6 Fix
2021-04-14 18:43:53 +03:00

17 lines
344 B
Go

package illegal_test
import (
"testing"
"unsafe"
"github.com/stretchr/testify/assert"
"gitlab.com/slon/shad-go/illegal"
)
func TestStringFromBytes(t *testing.T) {
b := []byte{'a', 'b', 'c'}
s := illegal.StringFromBytes(b)
assert.Equal(t, "abc", s)
assert.Equal(t, *(*uintptr)(unsafe.Pointer(&b)), *(*uintptr)(unsafe.Pointer(&s)))
}