Very nice looking tests!

Signed-off-by: Kris Nóva <kris@nivenly.com>
This commit is contained in:
Kris Nóva 2021-02-09 16:00:02 -08:00
parent 3b41c9dd5f
commit c1a45bf8e3
149 changed files with 1241 additions and 443 deletions

View file

@ -1,10 +1,9 @@
package reflect2
import (
"github.com/modern-go/concurrent"
"reflect"
"unsafe"
"github.com/modern-go/concurrent"
)
type Type interface {
@ -137,7 +136,7 @@ type frozenConfig struct {
func (cfg Config) Froze() *frozenConfig {
return &frozenConfig{
useSafeImplementation: cfg.UseSafeImplementation,
cache: concurrent.NewMap(),
cache: concurrent.NewMap(),
}
}
@ -292,8 +291,8 @@ func UnsafeCastString(str string) []byte {
stringHeader := (*reflect.StringHeader)(unsafe.Pointer(&str))
sliceHeader := &reflect.SliceHeader{
Data: stringHeader.Data,
Cap: stringHeader.Len,
Len: stringHeader.Len,
Cap: stringHeader.Len,
Len: stringHeader.Len,
}
return *(*[]byte)(unsafe.Pointer(sliceHeader))
}