mirror of https://github.com/knative/pkg.git
Adding string pointer. (#380)
This commit is contained in:
parent
dd77be3b9f
commit
5eb61f623a
|
@ -27,3 +27,9 @@ func Int64(i int64) *int64 {
|
|||
func Bool(b bool) *bool {
|
||||
return &b
|
||||
}
|
||||
|
||||
// String is a helper for turning strings into pointers for use in
|
||||
// API types that want *string.
|
||||
func String(s string) *string {
|
||||
return &s
|
||||
}
|
||||
|
|
|
@ -33,3 +33,11 @@ func TestBool(t *testing.T) {
|
|||
t.Errorf("Bool() = &%v, wanted %v", *gotPtr, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestString(t *testing.T) {
|
||||
want := "should be a pointer"
|
||||
gotPtr := String(want)
|
||||
if want != *gotPtr {
|
||||
t.Errorf("String() = &%v, wanted %v", *gotPtr, want)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue