Documentation ¶
Overview ¶
Package tf provides common test functions
Index ¶
- func B64(t *testing.T, b []byte) string
- func B64Dec(t *testing.T, s string) []byte
- func Different(t *testing.T, desc string, got, want any) bool
- func ECDSA(t *testing.T) (pubID [sha256.Size]byte, pubDER []byte, pub crypto.PublicKey, ...)
- func Ed25519(t *testing.T) (pubID [sha256.Size]byte, pubDER []byte, pub crypto.PublicKey, ...)
- func Ed25519Sign(t *testing.T, priv *ed25519.PrivateKey, msg []byte) []byte
- func Equal(t *testing.T, desc string, got, want any) bool
- func Error(t *testing.T, desc string, err error) bool
- func MapOptions(t *testing.T, usage string) map[byte]string
- func RSA(t *testing.T, bits int) (pubID [sha256.Size]byte, pubDER []byte, pub crypto.PublicKey, ...)
- func RSASign(t *testing.T, priv *rsa.PrivateKey, msg []byte) (sig []byte)
- func ReplaceShortWithLong(t *testing.T, usage, cmdLine string) (ret string)
- type Transport
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Different ¶
Different checks if a and b are not deeply equal, see reflect.DeepEqual(). An error is printed if a and b are equal. The output is then set to false.
func ECDSA ¶
func ECDSA(t *testing.T) (pubID [sha256.Size]byte, pubDER []byte, pub crypto.PublicKey, priv *ecdsa.PrivateKey)
ECDSA outputs a new ECDSA public-key pair
func Ed25519 ¶
func Ed25519(t *testing.T) (pubID [sha256.Size]byte, pubDER []byte, pub crypto.PublicKey, priv *ed25519.PrivateKey)
Ed25519 outputs a new Ed25519 public-key pair
func Ed25519Sign ¶
Ed25519Sign signs a message using Ed25519
func Equal ¶
Equal checks if a and b are deeply equal, see reflect.DeepEqual(). An error is printed if a and b are not equal. The output is then set to false.
func Error ¶
Error checks if an error from a previous operation was expected by checking if desc starts with the string "valid". An error is printed if the value of err is unexpected. True is returned if err is non-nil or wrongly nil.
func MapOptions ¶
MapOptions extracts options from lines in a usage message that starts with:
<space><space>-<character>,<space>--<characters>:
func RSA ¶
func RSA(t *testing.T, bits int) (pubID [sha256.Size]byte, pubDER []byte, pub crypto.PublicKey, priv *rsa.PrivateKey)
RSA outputs a new RSA public-key pair
func ReplaceShortWithLong ¶
ReplaceShortWithLong transforms a command-line string with short options to an equivalent one with long options, substituting from a usage message. The usage message must be formatted as described in MapOptions, see above.
Be warned: substitution is not be perfect, but it should be good enough to not cause headaches while catching most inconsistencies between usage messages and the parameters which are passed to a command's flag set.
Types ¶
type Transport ¶
type Transport struct {
// contains filtered or unexported fields
}
Transport implements the http.RoundTripper interface for use in tests
func NewTransport ¶
NewTransport outputs a new test transport