errors_test.go 697 B

123456789101112131415161718192021222324252627
  1. // Copyright 2014 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. // See https://code.google.com/p/go/source/browse/CONTRIBUTORS
  5. // Licensed under the same terms as Go itself:
  6. // https://code.google.com/p/go/source/browse/LICENSE
  7. package http2
  8. import "testing"
  9. func TestErrCodeString(t *testing.T) {
  10. tests := []struct {
  11. err ErrCode
  12. want string
  13. }{
  14. {ErrCodeProtocol, "PROTOCOL_ERROR"},
  15. {0xd, "HTTP_1_1_REQUIRED"},
  16. {0xf, "unknown error code 0xf"},
  17. }
  18. for i, tt := range tests {
  19. got := tt.err.String()
  20. if got != tt.want {
  21. t.Errorf("%d. Error = %q; want %q", i, got, tt.want)
  22. }
  23. }
  24. }