mirror of
https://github.com/hanzo-ml/kuberay.git
synced 2026-10-30 19:48:47 +00:00
27 lines
637 B
Go
27 lines
637 B
Go
package strconv
|
|
|
|
import (
|
|
"testing"
|
|
"unsafe"
|
|
|
|
"github.com/onsi/gomega"
|
|
|
|
utils "github.com/ray-project/kuberay/ray-operator/pkg/utils"
|
|
)
|
|
|
|
func TestStringConversion(t *testing.T) {
|
|
g := gomega.NewWithT(t)
|
|
|
|
str := "hello world"
|
|
|
|
// Test string to byte array conversion.
|
|
arr := utils.ConvertStringToByteSlice(str)
|
|
g.Expect(arr).Should(gomega.Equal([]byte(str)))
|
|
g.Expect(&arr[0]).Should(gomega.Equal(unsafe.StringData(str)))
|
|
|
|
// Test byte array to string conversion.
|
|
convStr := utils.ConvertByteSliceToString(arr)
|
|
g.Expect(str).Should(gomega.Equal(convStr))
|
|
g.Expect(unsafe.StringData(convStr)).Should(gomega.Equal(&arr[0]))
|
|
}
|