Add a benchmark for precompleted context creation
[go-signalcontext.git] / error_test.go
1 package signalcontext
2
3 import (
4 "os"
5 "testing"
6
7 "github.com/stretchr/testify/assert"
8 )
9
10 func TestError(t *testing.T) {
11 assert.EqualError(t, Error{os.Interrupt},
12 "received signal: "+os.Interrupt.String())
13 }
14
15 func BenchmarkError(b *testing.B) {
16 expected := "received signal: " + os.Interrupt.String()
17 for i := 0; i < b.N; i++ {
18 if s := (Error{os.Interrupt}).String(); s != expected {
19 b.Fatalf("expected %s, got %s", s, expected)
20 }
21 }
22 }