github.com/go-playground/pkg/v5@v5.29.1/unsafe/conversions_test.go (about) 1 package unsafeext 2 3 import "testing" 4 5 func TestBytesToString(t *testing.T) { 6 b := []byte{'g', 'o', '-', 'p', 'l', 'a', 'y', 'g', 'r', 'o', 'u', 'n', 'd'} 7 s := BytesToString(b) 8 expected := string(b) 9 if s != expected { 10 t.Fatalf("expected '%s' got '%s'", expected, s) 11 } 12 } 13 14 func TestStringToBytes(t *testing.T) { 15 s := "go-playground" 16 b := StringToBytes(s) 17 18 if string(b) != s { 19 t.Fatalf("expected '%s' got '%s'", s, string(b)) 20 } 21 }