panics: use the new facilities of testing.B instead

Lots of panics go away.
Also fix a name error in html/template.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5498045
This commit is contained in:
Rob Pike 2011-12-20 10:36:25 -08:00
parent b9697d4a58
commit 6b772462e4
18 changed files with 54 additions and 73 deletions

View file

@ -8,7 +8,6 @@ import (
"bytes"
"io"
"reflect"
"strconv"
. "strings"
"testing"
"unicode"
@ -143,7 +142,7 @@ const benchmarkString = "some_text=some☺value"
func BenchmarkIndexRune(b *testing.B) {
if got := IndexRune(benchmarkString, '☺'); got != 14 {
panic("wrong index: got=" + strconv.Itoa(got))
b.Fatalf("wrong index: expected 14, got=%d", got)
}
for i := 0; i < b.N; i++ {
IndexRune(benchmarkString, '☺')
@ -152,7 +151,7 @@ func BenchmarkIndexRune(b *testing.B) {
func BenchmarkIndexRuneFastPath(b *testing.B) {
if got := IndexRune(benchmarkString, 'v'); got != 17 {
panic("wrong index: got=" + strconv.Itoa(got))
b.Fatalf("wrong index: expected 17, got=%d", got)
}
for i := 0; i < b.N; i++ {
IndexRune(benchmarkString, 'v')
@ -161,7 +160,7 @@ func BenchmarkIndexRuneFastPath(b *testing.B) {
func BenchmarkIndex(b *testing.B) {
if got := Index(benchmarkString, "v"); got != 17 {
panic("wrong index: got=" + strconv.Itoa(got))
b.Fatalf("wrong index: expected 17, got=%d", got)
}
for i := 0; i < b.N; i++ {
Index(benchmarkString, "v")