core/cerror/error_test.go

24 lines
509 B
Go
Raw Normal View History

2023-05-19 04:12:21 +00:00
package cerror
import (
"testing"
"git.twelvetwelve.org/library/core/testutil/assert"
)
func TestError_Errors(t *testing.T) {
c := NewCode("org.twelvetwelve.one")
assert.NotNil(t, c)
e := New(c, "something went wrong")
assert.NotNil(t, e)
assert.Equal(t, e.Code(), c)
assert.WillPanic(t, func() { _ = NewCode("org.twelvetwelve.one") })
assert.WillPanic(t, func() { _ = GetCode("org.twelvetwelve.two") })
c2 := NewCode("org.twelvetwelve.two")
assert.NotNil(t, c2)
assert.NotEqual(t, c, c2)
}