Documentation ¶
Index ¶
- Variables
- func GetTestField(fname protoreflect.Name) protoreflect.FieldDescriptor
- func MakeTestCodec(fname protoreflect.Name, nonTerminal bool) (ormfield.Codec, error)
- func TestFieldSpecsGen(minLen, maxLen int) *rapid.Generator
- func TestKeyCodecGen(minLen, maxLen int) *rapid.Generator
- type TestFieldSpec
- type TestKeyCodec
Constants ¶
This section is empty.
Variables ¶
View Source
var GenA = rapid.Custom(func(t *rapid.T) *testpb.ExampleTable { a := &testpb.ExampleTable{} ref := a.ProtoReflect() for _, spec := range TestFieldSpecs { field := GetTestField(spec.FieldName) value := spec.Gen.Draw(t, string(spec.FieldName)) ref.Set(field, protoreflect.ValueOf(value)) } return a })
View Source
var TestFieldSpecs = []TestFieldSpec{ { "u32", rapid.Uint32(), }, { "u64", rapid.Uint64(), }, { "str", rapid.String().Filter(func(x string) bool { return strings.IndexByte(x, 0) < 0 }), }, { "bz", rapid.SliceOfN(rapid.Byte(), 0, math.MaxUint32), }, { "i32", rapid.Int32(), }, { "f32", rapid.Uint32(), }, { "s32", rapid.Int32(), }, { "sf32", rapid.Int32(), }, { "i64", rapid.Int64(), }, { "f64", rapid.Uint64(), }, { "s64", rapid.Int64(), }, { "sf64", rapid.Int64(), }, { "b", rapid.Bool(), }, { "ts", rapid.Custom(func(t *rapid.T) protoreflect.Message { seconds := rapid.Int64Range(-9999999999, 9999999999).Draw(t, "seconds").(int64) nanos := rapid.Int32Range(0, 999999999).Draw(t, "nanos").(int32) return (×tamppb.Timestamp{ Seconds: seconds, Nanos: nanos, }).ProtoReflect() }), }, { "dur", rapid.Custom(func(t *rapid.T) protoreflect.Message { seconds := rapid.Int64Range(0, 315576000000).Draw(t, "seconds").(int64) nanos := rapid.Int32Range(0, 999999999).Draw(t, "nanos").(int32) return (&durationpb.Duration{ Seconds: seconds, Nanos: nanos, }).ProtoReflect() }), }, { "e", rapid.Int32().Map(func(x int32) protoreflect.EnumNumber { return protoreflect.EnumNumber(x) }), }, }
Functions ¶
func GetTestField ¶
func GetTestField(fname protoreflect.Name) protoreflect.FieldDescriptor
func MakeTestCodec ¶
func TestFieldSpecsGen ¶
func TestKeyCodecGen ¶
Types ¶
type TestFieldSpec ¶
type TestFieldSpec struct { FieldName protoreflect.Name Gen *rapid.Generator }
TestFieldSpec defines a test field against the testpb.ExampleTable message.
type TestKeyCodec ¶
type TestKeyCodec struct { KeySpecs []TestFieldSpec Codec *ormkv.KeyCodec }
func (TestKeyCodec) Draw ¶
func (k TestKeyCodec) Draw(t *rapid.T, id string) []protoreflect.Value
Click to show internal directories.
Click to hide internal directories.