...
Source file
src/errors/errors_test.go
Documentation: errors
1
2
3
4
5 package errors_test
6
7 import (
8 "errors"
9 "testing"
10 )
11
12 func TestNewEqual(t *testing.T) {
13
14 if errors.New("abc") == errors.New("abc") {
15 t.Errorf(`New("abc") == New("abc")`)
16 }
17 if errors.New("abc") == errors.New("xyz") {
18 t.Errorf(`New("abc") == New("xyz")`)
19 }
20
21
22 err := errors.New("jkl")
23 if err != err {
24 t.Errorf(`err != err`)
25 }
26 }
27
28 func TestErrorMethod(t *testing.T) {
29 err := errors.New("abc")
30 if err.Error() != "abc" {
31 t.Errorf(`New("abc").Error() = %q, want %q`, err.Error(), "abc")
32 }
33 }
34
View as plain text