all: remove usage of constant errors

This commit is contained in:
Aleksandr Razumov
2017-02-11 06:54:37 +03:00
parent 03525bd44e
commit f1b2352162
8 changed files with 46 additions and 61 deletions

View File

@@ -212,6 +212,19 @@ func BenchmarkErrorCodeAttribute_AddTo(b *testing.B) {
}
}
func BenchmarkErrorCodeAttribute_GetFrom(b *testing.B) {
m := New()
b.ReportAllocs()
a := &ErrorCodeAttribute{
Code: 404,
Reason: []byte("not found!"),
}
a.AddTo(m)
for i := 0; i < b.N; i++ {
a.GetFrom(m)
}
}
func TestMessage_AddErrorCode(t *testing.T) {
m := New()
transactionID, err := base64.StdEncoding.DecodeString("jxhBARZwX+rsC6er")
@@ -243,3 +256,11 @@ func TestMessage_AddErrorCode(t *testing.T) {
t.Error("bad reason", string(errCodeAttr.Reason))
}
}
func BenchmarkMessage_GetNotFound(b *testing.B) {
m := New()
b.ReportAllocs()
for i := 0; i < b.N; i++ {
m.Get(AttrRealm)
}
}