github.com/gogf/gf@v1.16.9/util/gconv/gconv_z_unit_unsafe_test.go (about)

     1  // Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
     2  //
     3  // This Source Code Form is subject to the terms of the MIT License.
     4  // If a copy of the MIT was not distributed with this file,
     5  // You can obtain one at https://github.com/gogf/gf.
     6  
     7  package gconv_test
     8  
     9  import (
    10  	"github.com/gogf/gf/test/gtest"
    11  	"github.com/gogf/gf/util/gconv"
    12  	"testing"
    13  )
    14  
    15  func Test_Unsafe(t *testing.T) {
    16  	gtest.C(t, func(t *gtest.T) {
    17  		s := "I love 小泽玛利亚"
    18  		t.AssertEQ(gconv.UnsafeStrToBytes(s), []byte(s))
    19  	})
    20  
    21  	gtest.C(t, func(t *gtest.T) {
    22  		b := []byte("I love 小泽玛利亚")
    23  		t.AssertEQ(gconv.UnsafeBytesToStr(b), string(b))
    24  	})
    25  }