test

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2018 License: GPL-3.0, GPL-3.0-or-later Imports: 5 Imported by: 0

Documentation

Overview

Package test contains testing utils functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Marshal

func Marshal(t *testing.T, testCases MarshallingCases)

Marshal run testCases on json.Marshal function.

func MarshalUnmarshalled

func MarshalUnmarshalled(t *testing.T, testCases MarshallingCases)

MarshalUnmarshalled first Unmarshal tc.JSON, then Marshal result from previous operation.

func PrettyDiff

func PrettyDiff(t *testing.T, expected, actual string)

PrettyDiff print pretty diff of expected and actual using t.Errorf().

func PrettyMarshal

func PrettyMarshal(toMarshall interface{}) string

PrettyMarshal return prettified json representation of the argument. Return empty string, if argument can not be represented as json.

func Unmarshal

func Unmarshal(t *testing.T, testCases MarshallingCases)

Unmarshal run test cases on json.Unmarshal function.

func UnmarshalMarshalled

func UnmarshalMarshalled(t *testing.T, testCases MarshallingCases)

UnmarshalMarshalled first Marshal tc.Model, then Unmarshal result from previous operation.

Types

type MarshallingCases

type MarshallingCases []struct {
	Model interface{}

	// JSON which is compared to json.Marshal result.
	// JSON can be in any valid format. Indents and white spaces are ignored.
	JSON string
}

MarshallingCases contains test cases for Marshalling Test functions.

Jump to

Keyboard shortcuts

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