2021-04-14 15:41:01 +00:00
|
|
|
package illegal_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
"unsafe"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
2022-04-17 15:28:33 +00:00
|
|
|
|
2023-10-02 19:32:41 +00:00
|
|
|
"gitlab.com/manytask/itmo-go/private/illegal"
|
2021-04-14 15:41:01 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestStringFromBytes(t *testing.T) {
|
|
|
|
b := []byte{'a', 'b', 'c'}
|
|
|
|
s := illegal.StringFromBytes(b)
|
|
|
|
|
|
|
|
assert.Equal(t, "abc", s)
|
2021-04-14 15:43:53 +00:00
|
|
|
assert.Equal(t, *(*uintptr)(unsafe.Pointer(&b)), *(*uintptr)(unsafe.Pointer(&s)))
|
2021-04-14 15:41:01 +00:00
|
|
|
}
|