Documentation ¶
Overview ¶
Package test bundles a bunch of useful functions useful for testing purposes, particular useful in conjunction with the standard go test harness
The AssertMainThread() and AssertNonMainThread() functions require a bit of explanation. When compiled with the "assertions" tag these functions will panic if the calling function is in the wrong thread. Otherwise they are stubbed.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertMainThread ¶
func AssertMainThread()
AssertMainThread is a stub for when "assertions" build tag is missing.
func AssertNonMainThread ¶
func AssertNonMainThread()
AssertNonMainThread is a stub for when "assertions" build tag is missing.
func Equate ¶
Equate is used to test equality between one value and another. Generally, both values must be of the same type but if a is of type uint16, b can be uint16 or int. The reason for this is that a literal number value is of type int. It is very convenient to write something like this, without having to cast the expected number value:
var r uint16 r = someFunction() test.Equate(t, r, 10)
This is by no means a comprehensive comparison function. With a bit more work with the reflect package we could generalise the testing a lot more. At is is however, it's good enough.
func ExpectedFailure ¶
ExpectedFailure tests argument v for a failure condition suitable for it's type. Currentlly support types:
bool -> bool == false error -> error != nil
If type is nil then the test will fail.
func ExpectedSuccess ¶
ExpectedSuccess tests argument v for a success condition suitable for it's type. Currentlly support types:
bool -> bool == true error -> error == nil
If type is nil then the test will succeed.
Types ¶
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer is an implementation of the io.Writer interface. It should be used to capture output and to compare with predefined strings.