github.com/jingruilea/kubeedge@v1.2.0-beta.0.0.20200410162146-4bb8902b3879/edge/pkg/edgehub/common/assert.go (about) 1 package hubclient 2 3 import ( 4 "testing" 5 ) 6 7 // AssertNoError triggers testing error if the passed-in err is not nil. 8 func AssertNoError(t *testing.T, err error, errMsg string) { 9 if err != nil { 10 t.Errorf("%s, error: %s", errMsg, err.Error()) 11 } 12 } 13 14 // AssertTrue triggers testing error if the passed-in is true. 15 func AssertTrue(t *testing.T, value bool, errMsg string) { 16 if !value { 17 t.Errorf("error: %s", errMsg) 18 } 19 } 20 21 // AssertStringEqual triggers testing error if the expect and actual string are not the same. 22 func AssertStringEqual(t *testing.T, expect, actual, errMsg string) { 23 if expect != actual { 24 t.Errorf("%s, expect: \"%s\", actual: \"%s\"", errMsg, expect, actual) 25 } 26 } 27 28 // AssertIntEqual triggers testing error if the expect and actual int value are not the same. 29 func AssertIntEqual(t *testing.T, expect, actual, errMsg string) { 30 if expect != actual { 31 t.Errorf("%s, expect: \"%s\", actual: \"%s\"", errMsg, expect, actual) 32 } 33 }