testutil

package
v0.0.57 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 17, 2021 License: Apache-2.0, NCSA Imports: 13 Imported by: 2

Documentation

Overview

Package testutil contains common utilities to test Kythe libraries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeepEqual added in v0.0.9

func DeepEqual(expected, got interface{}) error

DeepEqual determines if expected is deeply equal to got, returning a detailed error if not. It is okay for expected and got to be protobuf message values.

func Errorf added in v0.0.7

func Errorf(t *testing.T, msg string, err error, args ...interface{})

Errorf calls t.Errorf(msg, err, args...) if err != nil

func FatalOnErr

func FatalOnErr(b *testing.B, msg string, err error, args ...interface{})

FatalOnErr calls b.Fatalf(msg, err, args...) if err != nil

func FatalOnErrT

func FatalOnErrT(t *testing.T, msg string, err error, args ...interface{})

FatalOnErrT calls t.Fatalf(msg, err, args...) if err != nil

func JSONEqual added in v0.0.30

func JSONEqual(expected, got []byte) error

JSONEqual compares two bytes assuming they are json, using encoding/json and DeepEqual.

func RandBytes

func RandBytes(bytes []byte)

RandBytes fills the given slice with random bytes

func RandStr

func RandStr(size int) string

RandStr returns a random string of the given length

func TestFilePath added in v0.0.29

func TestFilePath(t *testing.T, path string) string

TestFilePath takes a path and resolves it based on the testdir. If it cannot successfully do so, it calls t.Fatal and abandons.

func TrimmedEqual added in v0.0.29

func TrimmedEqual(got, want []byte) (bool, string)

TrimmedEqual compares two strings after collapsing irrelevant whitespace at the beginning or end of lines. It returns both a boolean indicating equality, as well as any relevant diff.

func YAMLEqual added in v0.0.30

func YAMLEqual(expected, got []byte) error

YAMLEqual compares two bytes assuming they are yaml, by converting to json and doing an ordering-agnostic comparison. Note this carries some restrictions because yaml->json conversion fails for nil or binary map keys.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL