matrixtest

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2020 License: MIT Imports: 5 Imported by: 0

README

matrixtest

Package matrixtest provides tools for testing with matrixed testcases.

Installation

go get -u github.com/bgpat/matrixtest

Usage

func Test(t *testing.T) {
	type testcase struct {
		Bool    bool
		Int     int
		String  string
		Pointer *struct{}
		Slice   []byte
	}
	testcases := map[string]interface{}{
		"bool":    testcase{Bool: true},
		"int":     testcase{Int: 1},
		"string":  testcase{String: "test"},
		"pointer": testcase{Pointer: &struct{}{}},
		"slice":   testcase{Slice: []byte("test")},
	}
	matrixtest.Run(t, testcases, func(testcase interface{}) func(t *testing.T) {
		return func(t *testing.T) {
			t.Log(testcase)
		}
	})
}

Documentation

Overview

Package matrixtest provides tools for testing with matrixed testcases.

Installation:

go get -u github.com/bgpat/matrixtest

Usage:

func Test(t *testing.T) {
	type testcase struct {
		Bool    bool
		Int     int
		String  string
		Pointer *struct{}
		Slice   []byte
	}
	testcases := map[string]interface{}{
		"bool":    testcase{Bool: true},
		"int":     testcase{Int: 1},
		"string":  testcase{String: "test"},
		"pointer": testcase{Pointer: &struct{}{}},
		"slice":   testcase{Slice: []byte("test")},
	}
	matrixtest.Run(t, testcases, func(testcase interface{}) func(t *testing.T) {
		return func(t *testing.T) {
			t.Log(testcase)
		}
	})
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(t *testing.T, matrix map[string]interface{}, f func(testcase interface{}) func(t *testing.T))

Run tests with the matrixed testcases.

Types

This section is empty.

Jump to

Keyboard shortcuts

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