Пример #1
0
// Test that AsEx(e).Reason() for exception e is e.
func TestAsExEx(t *testing.T) {
	examples := []string{"", "1", "abcdef"}
	for _, es := range examples {
		e := Ex(es)
		assert.Same(t, e, AsEx(e))
	}
}
Пример #2
0
// Test that AsEx(e).Reason() for usual error e is e.
func TestAsEx(t *testing.T) {
	examples := []string{"", "1", "abcdef"}
	for _, es := range examples {
		e := New(es)
		asEx := AsEx(e)
		if asEx, ok := asEx.(ExError); ok {
			assert.Same(t, e, asEx.Reason())
		} else {
			t.Error(fmt.Sprintf("Expected %v to be of type ExError.", asEx))
		}
	}
}
Пример #3
0
// Test that AsEx(nil) is nil.
func TestAsExNil(t *testing.T) {
	assert.Same(t, nil, AsEx(nil))
}
Пример #4
0
// Test that WrapEx(e).Reason() is e.
func TestWrapEx(t *testing.T) {
	examples := []error{nil, New(""), New("1"), New("abcdef"), Ex("abcdef")}
	for _, e := range examples {
		assert.Same(t, e, WrapEx(e).Reason())
	}
}