github.com/alloyzeus/go-azfl@v0.0.0-20231220071816-9740126a2d07/errors/errors_test.go (about) 1 package errors 2 3 import ( 4 "reflect" 5 "testing" 6 ) 7 8 const errNotFound = constantErrorDescriptor("not found") 9 10 func TestAssorted(t *testing.T) { 11 var nf error = errNotFound 12 var nf2 error = errNotFound 13 var nf3 error = constantErrorDescriptor("not found") 14 if nf != constantErrorDescriptor("not found") { 15 t.Errorf("%#v %#v", nf, constantErrorDescriptor("not found")) 16 } 17 if nf != nf2 { 18 t.Errorf("nf == nf2") 19 } 20 if nf != nf3 { 21 t.Errorf("nf == nf3") 22 } 23 if _, ok := nf.(constantErrorDescriptor); !ok { 24 t.Errorf("nf.(errorConstantDescriptor") 25 } 26 if nf3.Error() == "" { 27 t.Errorf(`nf3.Error() == "" -- %q`, nf3.Error()) 28 } 29 if IsEntNotFoundError(nf) { 30 t.Errorf("IsEntNotFound(nf)") 31 } 32 } 33 34 func assert(t *testing.T, expected interface{}, actual interface{}) { 35 t.Helper() 36 if !reflect.DeepEqual(expected, actual) { 37 t.Fatalf("\n\tExpected: %#v\n\tActual: %#v", expected, actual) 38 } 39 } 40 41 func assertNotEqual(t *testing.T, referenceValue interface{}, actualValue interface{}) { 42 t.Helper() 43 if reflect.DeepEqual(referenceValue, actualValue) { 44 t.Fatalf("\n\tNot expected: %#v\n\tActual: %#v", referenceValue, actualValue) 45 } 46 }