1// Copyright 2011 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
5package errors_test
6
7import (
8	"errors"
9	"testing"
10)
11
12func TestNewEqual(t *testing.T) {
13	// Different allocations should not be equal.
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	// Same allocation should be equal to itself (not crash).
22	err := errors.New("jkl")
23	if err != err {
24		t.Errorf(`err != err`)
25	}
26}
27
28func 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