helpers

package module
v0.0.0-...-febb253 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetFunctionBodyText

func GetFunctionBodyText(text string, functionName string) (bool, string)

Returns the specified function body text. First return value = true if function was found, otherwise false Second return value = function body text

func RemoveAllComments

func RemoveAllComments(text string) string

Removes all comments from the specified text and returns filtered text

func RunFunctionAnatomyTests

func RunFunctionAnatomyTests(testFuncs []FuncAnatomyTest, t *testing.T)

Runs standard function anatomy tests

func RunFunctionOutputTests

func RunFunctionOutputTests(testFuncs []FuncOutputTest, randomSeed int64, t *testing.T)

Runs standard function output tests using provided values

func RunInstantiateObjectsTest

func RunInstantiateObjectsTest(text string, objectName string, minObjectCount int, maxObjectCount int, t *testing.T)

Tests specified code text to make sure the correct number of the specified objects are instantiated in the code

func RunInstantiateObjectsTestWithFunctionName

func RunInstantiateObjectsTestWithFunctionName(text string, objectName string, minObjectCount int, maxObjectCount int, objInstantiatedFuncName string, t *testing.T)

Tests specified code text to make sure the correct number of the specified objects are instantiated in the code.

func RunMethodAnatomyTest

func RunMethodAnatomyTest(testObject interface{}, methodTest MethodAnatomyTest, t *testing.T) bool

Runs standard struct method anatomy test using provided values. Returns true if anatomy passes tests. Otherwise returns false. IMPORTANT: testObject must be a pointer to the struct object being tested!

func RunMethodAnatomyTests

func RunMethodAnatomyTests(testObject interface{}, methodTests []MethodAnatomyTest, t *testing.T)

Runs standard struct method anatomy tests using provided values IMPORTANT: testObject must be a pointer to the struct object being tested!

func RunMethodOutputTest

func RunMethodOutputTest(testObject interface{}, methodTest MethodOutputTest, randomSeed int64, t *testing.T) reflect.Value

Runs standard struct method output test. Returns provided object after method has been invoked for further evaluation. IMPORTANT: testObject must be a pointer to the struct object being tested!

func RunMethodOutputTests

func RunMethodOutputTests(testObject interface{}, methodTests []MethodOutputTest, randomSeed int64, t *testing.T)

Runs standard struct method output tests using provided values IMPORTANT: testObject must be a pointer to the struct object being tested!

func RunRandomNumberTemplateTest

func RunRandomNumberTemplateTest(text string, t *testing.T)

Tests specified code text to confirm using proper random number seeding template

func RunValidateFlagArgTest

func RunValidateFlagArgTest(text string, flagType FlagType, flagName string, t *testing.T)

Tests specified code text to make sure specified command line flags are mapped to a variable of the appropriate type

func StandardRunTimeErrorCheck

func StandardRunTimeErrorCheck(t *testing.T)

This function is meant to be used by all unit tests in order to gracefully recover from runtime errors and provide a standard error message

Types

type FlagType

type FlagType int

FlagType enum

const (
	IntFlag    FlagType = iota
	StringFlag FlagType = iota
	FloatFlag  FlagType = iota
	BoolFlag   FlagType = iota
)

FlagType enum values

type FuncAnatomyTest

type FuncAnatomyTest struct {
	Name        string
	Obj         interface{}
	ArgTypes    []reflect.Type
	ReturnTypes []reflect.Type
}

Function anatomy testing struct

type FuncOutputTest

type FuncOutputTest struct {
	Name          string
	Obj           interface{}
	Args          []reflect.Value
	StdinStrings  []string
	IgnoreStdout  bool
	StdoutStrings []string
	IgnoreReturns bool
	Returns       []reflect.Value
}

Function output testing struct

type MethodAnatomyTest

type MethodAnatomyTest struct {
	Name        string
	ArgTypes    []reflect.Type
	ReturnTypes []reflect.Type
}

Method anatomy testing struct

type MethodOutputTest

type MethodOutputTest struct {
	Name          string
	Args          []reflect.Value
	StdinStrings  []string
	IgnoreStdout  bool
	StdoutStrings []string
	IgnoreReturns bool
	Returns       []reflect.Value
}

Method output testing struct

Jump to

Keyboard shortcuts

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