]> Cypherpunks repositories - gostls13.git/commit
fmt: refactor pointer formatting and improve tests
authorMartin Möhrmann <martisch@uos.de>
Sat, 5 Mar 2016 23:39:37 +0000 (00:39 +0100)
committerRob Pike <r@golang.org>
Wed, 9 Mar 2016 20:59:50 +0000 (20:59 +0000)
commit8e2315678667f498f50f0b38dd064e8cc7f6c215
treee0b37046cedbf604b95d54a65f0afe085649b532
parentbbd3ffbd838a2e172bff7b95a8df7f9e55b35786
fmt: refactor pointer formatting and improve tests

Uses a switch statement for direct format function selection
similar to other types verb handling in fmt.

Applies padding also to nil pointers formatted with %v.

Guards against "slice bounds out of range" panic in TestSprintf
when a pointer test results in a formatted string s
that is shorter than the index i the pointer should appear in.

Adds more and rearranges tests.

Fixes #14712
Fixes #14714

Change-Id: Iaf5ae37b7e6ba7d27d528d199f2b2eb9d5829b8c
Reviewed-on: https://go-review.googlesource.com/20371
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
src/fmt/fmt_test.go
src/fmt/print.go