MCPcopy
hub / github.com/rs/zerolog / TestSamplers

Function TestSamplers

sampler_test.go:76–92  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

74}
75
76func TestSamplers(t *testing.T) {
77 for i := range samplers {
78 s := samplers[i]
79 t.Run(s.name, func(t *testing.T) {
80 sampler := s.sampler()
81 got := 0
82 for t := s.total; t > 0; t-- {
83 if sampler.Sample(0) {
84 got++
85 }
86 }
87 if got < s.wantMin || got > s.wantMax {
88 t.Errorf("%s.Sample(0) == true %d on %d, want [%d, %d]", s.name, got, s.total, s.wantMin, s.wantMax)
89 }
90 })
91 }
92}
93
94func BenchmarkSamplers(b *testing.B) {
95 for i := range samplers {

Callers

nothing calls this directly

Calls 2

RunMethod · 0.65
SampleMethod · 0.65

Tested by

no test coverage detected