Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding ByteSlicePtr #399

Merged
merged 1 commit into from
May 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions autorest/to/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,8 @@ func Float64(i *float64) float64 {
func Float64Ptr(i float64) *float64 {
return &i
}

// ByteSlicePtr returns a pointer to the passed byte slice.
func ByteSlicePtr(b []byte) *[]byte {
return &b
}
8 changes: 8 additions & 0 deletions autorest/to/convert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,3 +232,11 @@ func TestFloat64Ptr(t *testing.T) {
v, *Float64Ptr(v))
}
}

func TestByteSlicePtr(t *testing.T) {
v := []byte("bytes")
if out := ByteSlicePtr(v); !reflect.DeepEqual(*out, v) {
t.Fatalf("to: ByteSlicePtr failed to return the correct slice -- expected %v, received %v",
v, *out)
}
}