for i := 0; i < b.N; i++ {
j := index(buf, 'x')
if j != n-1 {
- println("bad index", j)
- panic("bad index")
+ b.Fatal("bad index", j)
}
}
buf[n-1] = '\x00'
for i := 0; i < b.N; i++ {
eq := equal(buf1, buf2)
if !eq {
- panic("bad equal")
+ b.Fatal("bad equal")
}
}
buf1[n-1] = '\x00'
for i := 0; i < b.N; i++ {
j := index(buf, buf[n-7:])
if j != n-7 {
- println("bad index", j)
- panic("bad index")
+ b.Fatal("bad index", j)
}
}
buf[n-1] = '\x00'
for i := 0; i < b.N; i++ {
j := index(buf, buf[n-7:])
if j != n-7 {
- println("bad index", j)
- panic("bad index")
+ b.Fatal("bad index", j)
}
}
buf[n-1] = '\x00'
for i := 0; i < b.N; i++ {
j := count(buf, buf[n-7:])
if j != 1 {
- println("bad count", j)
- panic("bad count")
+ b.Fatal("bad count", j)
}
}
buf[n-1] = '\x00'
for i := 0; i < b.N; i++ {
j := count(buf, buf[n-7:])
if j != 1 {
- println("bad count", j)
- panic("bad count")
+ b.Fatal("bad count", j)
}
}
buf[n-1] = '\x00'
tt := encryptTests[0]
c, err := NewCipher(tt.key)
if err != nil {
- panic("NewCipher")
+ b.Fatal("NewCipher:", err)
}
out := make([]byte, len(tt.in))
b.StartTimer()
}
b.StopTimer()
if !reflect.DeepEqual(s, t) {
- panic("no match")
+ b.Fatal("no match")
}
}
}
b.StopTimer()
if !bytes.Equal(buf.Bytes(), big[:30]) {
- panic("first half doesn't match")
+ b.Fatalf("first half doesn't match: %x %x", buf.Bytes(), big[:30])
}
}
func BenchmarkEndToEndPipe(b *testing.B) {
r, w, err := os.Pipe()
if err != nil {
- panic("can't get pipe:" + err.Error())
+ b.Fatal("can't get pipe:", err)
}
benchmarkEndToEnd(r, w, b)
}
enc := NewEncoder(ioutil.Discard)
for i := 0; i < b.N; i++ {
if err := enc.Encode(&codeStruct); err != nil {
- panic(err)
+ b.Fatal("Encode:", err)
}
}
b.SetBytes(int64(len(codeJSON)))
}
for i := 0; i < b.N; i++ {
if _, err := Marshal(&codeStruct); err != nil {
- panic(err)
+ b.Fatal("Marshal:", err)
}
}
b.SetBytes(int64(len(codeJSON)))
buf.WriteByte('\n')
buf.WriteByte('\n')
if err := dec.Decode(&r); err != nil {
- panic(err)
+ b.Fatal("Decode:", err)
}
}
b.SetBytes(int64(len(codeJSON)))
for i := 0; i < b.N; i++ {
var r codeResponse
if err := Unmarshal(codeJSON, &r); err != nil {
- panic(err)
+ b.Fatal("Unmmarshal:", err)
}
}
b.SetBytes(int64(len(codeJSON)))
var r codeResponse
for i := 0; i < b.N; i++ {
if err := Unmarshal(codeJSON, &r); err != nil {
- panic(err)
+ b.Fatal("Unmmarshal:", err)
}
}
b.SetBytes(int64(len(codeJSON)))
func (e *Error) Error() string {
if e.Line != 0 {
- return fmt.Sprintf("exp/template/html:%s:%d: %s", e.Name, e.Line, e.Description)
+ return fmt.Sprintf("html/template:%s:%d: %s", e.Name, e.Line, e.Description)
} else if e.Name != "" {
- return fmt.Sprintf("exp/template/html:%s: %s", e.Name, e.Description)
+ return fmt.Sprintf("html/template:%s: %s", e.Name, e.Description)
}
- return "exp/template/html: " + e.Description
+ return "html/template: " + e.Description
}
// errorf creates an error given a format string f and args.
},
{
`<input type=button value=onclick=>`,
- `exp/template/html:z: "=" in unquoted attr: "onclick="`,
+ `html/template:z: "=" in unquoted attr: "onclick="`,
},
{
`<input type=button value= onclick=>`,
- `exp/template/html:z: "=" in unquoted attr: "onclick="`,
+ `html/template:z: "=" in unquoted attr: "onclick="`,
},
{
`<input type=button value= 1+1=2>`,
- `exp/template/html:z: "=" in unquoted attr: "1+1=2"`,
+ `html/template:z: "=" in unquoted attr: "1+1=2"`,
},
{
"<a class=`foo>",
- "exp/template/html:z: \"`\" in unquoted attr: \"`foo\"",
+ "html/template:z: \"`\" in unquoted attr: \"`foo\"",
},
{
`<a style=font:'Arial'>`,
- `exp/template/html:z: "'" in unquoted attr: "font:'Arial'"`,
+ `html/template:z: "'" in unquoted attr: "font:'Arial'"`,
},
{
`<a=foo>`,
}
dst = dst1
default:
- panic("unreachable")
+ b.Fatal("unknown destination color model", dcm)
}
var src image.Image
Rect: image.Rect(0, 0, srcw, srch),
}
default:
- panic("unreachable")
+ b.Fatal("unknown source color model", scm)
}
var mask image.Image
}
mask = mask1
default:
- panic("unreachable")
+ b.Fatal("unknown mask color model", mcm)
}
b.StartTimer()
}
}
if !img.Opaque() {
- panic("expected image to be opaque")
+ b.Fatal("expected image to be opaque")
}
b.SetBytes(640 * 480 * 4)
b.StartTimer()
}
}
if !img.Opaque() {
- panic("expected image to be opaque")
+ b.Fatal("expected image to be opaque")
}
b.SetBytes(640 * 480 * 4)
b.StartTimer()
b.StopTimer()
img := image.NewRGBA(image.Rect(0, 0, 640, 480))
if img.Opaque() {
- panic("expected image to not be opaque")
+ b.Fatal("expected image to not be opaque")
}
b.SetBytes(640 * 480 * 4)
b.StartTimer()
for i := 0; i < b.N; i++ {
_, err := Decode(r)
if err != nil {
- panic(err)
+ b.Fatal("Decode:", err)
}
}
}
package big
import (
- "fmt"
"io"
"strings"
"testing"
var s string
s = z.string(lowercaseDigits[0:base])
if t := toString(z, lowercaseDigits[0:base]); t != s {
- panic(fmt.Sprintf("scanning: got %s; want %s", s, t))
+ b.Fatalf("scanning: got %s; want %s", s, t)
}
b.StartTimer()
for i := 0; i < b.N; i++ {
res, err := Get(ts.URL)
if err != nil {
- panic("Get: " + err.Error())
+ b.Fatal("Get:", err)
}
all, err := ioutil.ReadAll(res.Body)
if err != nil {
- panic("ReadAll: " + err.Error())
+ b.Fatal("ReadAll:", err)
}
body := string(all)
if body != "Hello world.\n" {
- panic("Got body: " + body)
+ b.Fatal("Got body:", body)
}
}
for atomic.AddInt32(&N, -1) >= 0 {
err = client.Call("Arith.Add", args, reply)
if err != nil {
- fmt.Printf("Add: expected no error but got string %q", err.Error())
- panic("rpc error")
+ b.Fatalf("rpc error: Add: expected no error but got string %q", err.Error())
}
if reply.C != args.A+args.B {
- fmt.Printf("Add: expected %d got %d", reply.C, args.A+args.B)
- panic("rpc error")
+ b.Fatalf("rpc error: Add: expected %d got %d", reply.C, args.A+args.B)
}
}
wg.Done()
once.Do(startServer)
client, err := dial()
if err != nil {
- fmt.Println("error dialing", err)
- return
+ b.Fatalf("error dialing:", err)
}
// Asynchronous calls
}()
go func() {
for call := range res {
- a := call.Args.(*Args).A
- b := call.Args.(*Args).B
- c := call.Reply.(*Reply).C
- if a+b != c {
- fmt.Printf("Add: expected %d got %d", a+b, c)
- panic("incorrect reply")
+ A := call.Args.(*Args).A
+ B := call.Args.(*Args).B
+ C := call.Reply.(*Reply).C
+ if A+B != C {
+ b.Fatalf("incorrect reply: Add: expected %d got %d", A+B, C)
}
<-gate
if atomic.AddInt32(&recv, -1) == 0 {
b.StartTimer()
for i := 0; i < b.N; i++ {
if !re.MatchString(x) {
- println("no match!")
- break
+ b.Fatal("no match!")
}
}
}
b.StartTimer()
for i := 0; i < b.N; i++ {
if !re.MatchString(x) {
- println("no match!")
- break
+ b.Fatal("no match!")
}
}
}
b.StartTimer()
for i := 0; i < b.N; i++ {
if !re.MatchString(x) {
- println("no match!")
- break
+ b.Fatal("no match!")
}
}
}
b.StartTimer()
for i := 0; i < b.N; i++ {
if !re.MatchString(x) {
- println("no match!")
- break
+ b.Fatal("no match!")
}
}
}
b.StartTimer()
for i := 0; i < b.N; i++ {
if !re.MatchString(x) {
- println("no match!")
- break
+ b.Fatalf("no match!")
}
}
}
b.StartTimer()
for i := 0; i < b.N; i++ {
if !re.MatchString(x) {
- println("no match!")
- break
+ b.Fatalf("no match!")
}
}
}
b.StartTimer()
for i := 0; i < b.N; i++ {
if !re.MatchString(x) {
- println("no match!")
- break
+ b.Fatalf("no match!")
}
}
}
b.StartTimer()
for i := 0; i < b.N; i++ {
if !re.MatchString(x) {
- println("no match!")
- break
+ b.Fatalf("no match!")
}
}
}
b.SetBytes(int64(n))
for i := 0; i < b.N; i++ {
if r.Match(t) {
- panic("match!")
+ b.Fatal("match!")
}
}
}
"bytes"
"io"
"reflect"
- "strconv"
. "strings"
"testing"
"unicode"
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, '☺')
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')
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")