2021-01-17 21:46:25 +08:00
|
|
|
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
|
2019-08-09 09:14:48 +08:00
|
|
|
//
|
|
|
|
// This Source Code Form is subject to the terms of the MIT License.
|
|
|
|
// If a copy of the MIT was not distributed with this file,
|
|
|
|
// You can obtain one at https://github.com/gogf/gf.
|
|
|
|
|
|
|
|
package gconv_test
|
|
|
|
|
|
|
|
import (
|
2021-10-11 21:41:56 +08:00
|
|
|
"github.com/gogf/gf/v2/test/gtest"
|
|
|
|
"github.com/gogf/gf/v2/util/gconv"
|
2019-08-09 09:14:48 +08:00
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func Test_Unsafe(t *testing.T) {
|
2020-03-19 22:56:12 +08:00
|
|
|
gtest.C(t, func(t *gtest.T) {
|
2019-08-09 09:51:52 +08:00
|
|
|
s := "I love 小泽玛利亚"
|
2020-03-19 22:56:12 +08:00
|
|
|
t.AssertEQ(gconv.UnsafeStrToBytes(s), []byte(s))
|
2019-08-09 09:14:48 +08:00
|
|
|
})
|
|
|
|
|
2020-03-19 22:56:12 +08:00
|
|
|
gtest.C(t, func(t *gtest.T) {
|
2019-08-09 09:51:52 +08:00
|
|
|
b := []byte("I love 小泽玛利亚")
|
2020-03-19 22:56:12 +08:00
|
|
|
t.AssertEQ(gconv.UnsafeBytesToStr(b), string(b))
|
2019-08-09 09:14:48 +08:00
|
|
|
})
|
|
|
|
}
|