mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
print array (not just *array) using %v
TBR=rsc DELTA=34 (33 added, 0 deleted, 1 changed) OCL=21718 CL=21718
This commit is contained in:
parent
eb32228627
commit
b0d62676d2
2 changed files with 34 additions and 1 deletions
|
|
@ -232,3 +232,17 @@ export func TestStructPrinter(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
export func TestArrayPrinter(t *testing.T) {
|
||||
a := []int{1, 2, 3, 4, 5};
|
||||
want := "[1 2 3 4 5]";
|
||||
out := fmt.sprintf("%v", a);
|
||||
if out != want {
|
||||
t.Errorf("sprintf(%%v, array) = %q, want %q", out, want);
|
||||
}
|
||||
want = "&" + want;
|
||||
out = fmt.sprintf("%v", &a);
|
||||
if out != want {
|
||||
t.Errorf("sprintf(%%v, &array) = %q, want %q", out, want);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue