MCPcopy Index your code
hub / github.com/google/go-github / TestStringify_BufferPool

Function TestStringify_BufferPool

github/strings_test.go:133–168  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

131}
132
133func TestStringify_BufferPool(t *testing.T) {
134 t.Parallel()
135 // Verify that concurrent usage of Stringify is safe and doesn't corrupt buffers.
136 // While we can't easily verify reuse without exposing internal metrics,
137 // we can verify correctness under load which implies proper Reset() handling.
138 const goroutines = 10
139 const iterations = 100
140
141 errCh := make(chan error, goroutines)
142
143 for range goroutines {
144 go func() {
145 for range iterations {
146 // Use a mix of types to exercise different code paths
147 s1 := Stringify(123)
148 if s1 != "123" {
149 errCh <- fmt.Errorf("got %q, want %q", s1, "123")
150 return
151 }
152
153 s2 := Stringify("test")
154 if s2 != `"test"` {
155 errCh <- fmt.Errorf("got %q, want %q", s2, `"test"`)
156 return
157 }
158 }
159 errCh <- nil
160 }()
161 }
162
163 for range goroutines {
164 if err := <-errCh; err != nil {
165 t.Error(err)
166 }
167 }
168}
169
170// Directly test the String() methods on various GitHub types. We don't do an
171// exhaustive test of all the various field types, since TestStringify() above

Callers

nothing calls this directly

Calls 2

StringifyFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…