Documentation
¶
Overview ¶
The testutil package provides an assertion framework for unit testing. The package assumes these are executed in the context of gotest, and the first parameter of each method is the *testing.T parameter of the test method. If any assertion fails, the assertion calls t.Fatalf(), logs the message, and terminates the test method.
Index ¶
- func AssertEmptyString(t *testing.T, v string, format string, a ...interface{})
- func AssertEqual(t *testing.T, v1 interface{}, v2 interface{}, format string, a ...interface{})
- func AssertFalse(t *testing.T, b bool, format string, a ...interface{})
- func AssertFalseFunc(t *testing.T, v interface{}, f func(x interface{}) bool, format string, ...)
- func AssertGreaterThan(t *testing.T, v1 interface{}, v2 interface{}, format string, a ...interface{})
- func AssertGreaterThanOrEqual(t *testing.T, v1 interface{}, v2 interface{}, format string, a ...interface{})
- func AssertLessThan(t *testing.T, v1 interface{}, v2 interface{}, format string, a ...interface{})
- func AssertLessThanOrEqual(t *testing.T, v1 interface{}, v2 interface{}, format string, a ...interface{})
- func AssertNil(t *testing.T, v interface{}, format string, a ...interface{})
- func AssertNotEmptyString(t *testing.T, v string, format string, a ...interface{})
- func AssertNotNil(t *testing.T, v interface{}, format string, a ...interface{})
- func AssertStringsEqual(t *testing.T, v1 string, v2 string, format string, a ...interface{})
- func AssertStringsNotEqual(t *testing.T, v1 string, v2 string, format string, a ...interface{})
- func AssertTextInFiles(t *testing.T, fileMap map[int]string, needle string) (found bool)
- func AssertTextNotInFiles(t *testing.T, fileMap map[int]string, needle string) (found bool)
- func AssertTrue(t *testing.T, b bool, format string, a ...interface{})
- func AssertTrueFunc(t *testing.T, v interface{}, f func(x interface{}) bool, format string, ...)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertEmptyString ¶
Assert a string value is equal to the empty string (""). The method takes the t parameter from the test method, the value to be asserted, and a message printed if the assertion fails. The format and the a variadic parameters conform the the fmt.Fatalf() method.
If the assertion fails, t.Fatalf() is called terminating the test script.
func AssertEqual ¶
Assert that two values are equal. The method takes the t parameter from the test method, the values to be asserted, and a message printed if the assertion fails. The format and the a variadic parameters conform the the fmt.Fatalf() method. Assumes each of v1 and v2 are typed values (not constants)
If the assertion fails, t.Fatalf() is called terminating the test script.
func AssertFalse ¶
Assert a value evaluates to false The method takes the *t parameter from the test method, the value to be asserted, and a message printed if the assertion fails. The format and the a variadic parameters conform the the fmt.Fatalf() method.
If the assertion fails, t.Fatalf() is called terminating the test script.
func AssertFalseFunc ¶
func AssertFalseFunc(t *testing.T, v interface{}, f func(x interface{}) bool, format string, a ...interface{})
Assert the a function that accepts a parameter (v) returns false. The method takes the t parameter from the test method, the value to be asserted, and a message printed if the assertion fails. The format and the a variadic parameters conform the the fmt.Fatalf() method.
If the assertion fails, t.Fatalf() is called terminating the test script.
func AssertGreaterThan ¶
func AssertGreaterThan(t *testing.T, v1 interface{}, v2 interface{}, format string, a ...interface{})
Assert the first value (v1) is numerically greater than the second value (v2). The method takes the t parameter from the test method, the values to be asserted, and a message printed if the assertion fails. The format and the a variadic parameters conform the the fmt.Fatalf() method.
If the assertion fails, t.Fatalf() is called terminating the test script.
func AssertGreaterThanOrEqual ¶
func AssertGreaterThanOrEqual(t *testing.T, v1 interface{}, v2 interface{}, format string, a ...interface{})
Assert the first value (v1) is greater-than-or-equal-to the second value (v2) The method takes the t parameter from the test method, the value to be asserted, and a message printed if the assertion fails. The format and the a variadic parameters conform the the fmt.Fatalf() method.
If the assertion fails, t.Fatalf() is called terminating the test script.
func AssertLessThan ¶
Assert the first value (v1) is less-than the second value (v2) The method takes the t parameter from the test method, the value to be asserted, and a message printed if the assertion fails. The format and the a variadic parameters conform the the fmt.Fatalf() method.
If the assertion fails, t.Fatalf() is called terminating the test script.
func AssertLessThanOrEqual ¶
func AssertLessThanOrEqual(t *testing.T, v1 interface{}, v2 interface{}, format string, a ...interface{})
Assert the first value (v1) is less-than-or-equal-to the second value (v2) The method takes the *t parameter from the test method, the value to be asserted, and a message printed if the assertion fails. The format and the a variadic parameters conform the the fmt.Fatalf() method.
If the assertion fails, t.Fatalf() is called terminating the test script.
func AssertNil ¶
Assert a value is nil. The method takes the t paramteter from the test method, the value to be asserted as nil, and a message printed if the assertion fails. The format and the a variadic parameters conform the the fmt.Fatalf() method.
If the assertion fails, t.Fatalf() is called terminating the test script.
func AssertNotEmptyString ¶
Assert a string value is NOT equal to the empty string. The method takes the *t parameter from the test method, the value to be asserted, and a message printed if the assertion fails. The format and the a variadic parameters conform the the fmt.Fatalf() method.
If the assertion fails, t.Fatalf() is called terminating the test script.
func AssertNotNil ¶
Assert a value is NOT nil. The method takes the t paramteter from the test method, the value to be asserted as NOT nil, and a message printed if the assertion fails. The format and the a variadic parameters conform the the fmt.Fatalf() method.
If the assertion fails, t.Fatalf() is called terminating the test script.
func AssertStringsEqual ¶
Assert two strings are equivalent, i.e. have the string characters/runes. The method takes the *t parameter from the test method, the two strings to be asserted, and a message printed if the assertion fails. The format and the a variadic parameters conform the the fmt.Fatalf() method.
If the assertion fails, t.Fatalf() is called terminating the test script.
func AssertStringsNotEqual ¶
Assert two strinsg are NOT equivalent, i.e. the string values are not the same. The method takes the *t parameter from the test method, the value to be asserted, and a message printed if the assertion fails. The format and the a variadic parameters conform the the fmt.Fatalf() method.
If the assertion fails, t.Fatalf() is called terminating the test script.
func AssertTextInFiles ¶
Assert a given string is found in a list of files provided as a map[int]string. The method takes the t parameter from the test method, the value to be asserted, and a message printed if the assertion fails. The format and the a variadic parameters conform the the fmt.Fatalf() method.
If the assertion fails, t.Fatalf() is called terminating the test script.
func AssertTextNotInFiles ¶
Assert a given string is NOT found in a list of files provided as a map[int]string. The method takes the t parameter from the test method, the value to be asserted, and a message printed if the assertion fails. The format and the a variadic parameters conform the the fmt.Fatalf() method.
If the assertion fails, t.Fatalf() is called terminating the test script.
func AssertTrue ¶
Assert a value evaluates to true The method takes the t parameter from the test method, the value to be asserted, and a message printed if the assertion fails. The format and the a variadic parameters conform the the fmt.Fatalf() method.
If the assertion fails, t.Fatalf() is called terminating the test script.
func AssertTrueFunc ¶
func AssertTrueFunc(t *testing.T, v interface{}, f func(x interface{}) bool, format string, a ...interface{})
Assert the a function that accepts a parameter (v) returns true. The method takes the t parameter from the test method, the value to be asserted, and a message printed if the assertion fails. The format and the a variadic parameters conform the the fmt.Fatalf() method.
If the assertion fails, t.Fatalf() is called terminating the test script.
Types ¶
This section is empty.