fuzz

package
v1.127.0 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FillWithRandom

func FillWithRandom(t *testing.T, randStream *rand.Rand, msg proto.Message)

func Visit

func Visit(msgPath string, msg protoreflect.Message, setter func(v protoreflect.Value), visitor ProtoVisitor)

Types

type ClearFields

type ClearFields struct {
	ProtoVisitorBase

	Paths sets.Set[string]
}

func (*ClearFields) VisitList

func (v *ClearFields) VisitList(path string, msg protoreflect.List, setter func(v protoreflect.Value))

func (*ClearFields) VisitMap

func (v *ClearFields) VisitMap(path string, msg protoreflect.Map, setter func(v protoreflect.Value))

func (*ClearFields) VisitMessage

func (v *ClearFields) VisitMessage(path string, msg protoreflect.Message, setter func(v protoreflect.Value))

func (*ClearFields) VisitPrimitive

func (v *ClearFields) VisitPrimitive(path string, val protoreflect.Value, setter func(v protoreflect.Value))

type FillerConfig added in v1.127.0

type FillerConfig struct {
	Stream         *rand.Rand
	FieldOverrides map[string]OverrideFiller
}

type OverrideFiller added in v1.127.0

type OverrideFiller func(t *testing.T, fieldName string, field reflect.Value)

type ProtoVisitor

type ProtoVisitor interface {
	VisitPrimitive(path string, val protoreflect.Value, setter func(v protoreflect.Value))
	VisitMessage(path string, msg protoreflect.Message, setter func(v protoreflect.Value))
	VisitList(path string, msg protoreflect.List, setter func(v protoreflect.Value))
	VisitMap(path string, msg protoreflect.Map, setter func(v protoreflect.Value))
}

type ProtoVisitorBase

type ProtoVisitorBase struct {
}

func (*ProtoVisitorBase) VisitList

func (v *ProtoVisitorBase) VisitList(path string, msg protoreflect.List, setter func(v protoreflect.Value))

func (*ProtoVisitorBase) VisitMap

func (v *ProtoVisitorBase) VisitMap(path string, msg protoreflect.Map, setter func(v protoreflect.Value))

func (*ProtoVisitorBase) VisitMessage

func (v *ProtoVisitorBase) VisitMessage(path string, msg protoreflect.Message, setter func(v protoreflect.Value))

func (*ProtoVisitorBase) VisitPrimitive

func (v *ProtoVisitorBase) VisitPrimitive(path string, val protoreflect.Value, setter func(v protoreflect.Value))

type RandomFiller added in v1.126.0

type RandomFiller struct {
	// contains filtered or unexported fields
}

func NewRandomFiller added in v1.126.0

func NewRandomFiller(fc *FillerConfig) *RandomFiller

func (*RandomFiller) Fill added in v1.126.0

func (rf *RandomFiller) Fill(t *testing.T, obj interface{})

Fill populates the fields of a struct with random values. Enums are handled separately in the two maps passed to the RandomFiller.

type ReplaceFields

type ReplaceFields struct {
	ProtoVisitorBase

	Func func(path string, val protoreflect.Value) (protoreflect.Value, bool)
}

func (*ReplaceFields) VisitPrimitive

func (v *ReplaceFields) VisitPrimitive(path string, val protoreflect.Value, setter func(v protoreflect.Value))

Jump to

Keyboard shortcuts

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