MCPcopy Create free account
hub / github.com/eapache/channels / TestUnwrap

Function TestUnwrap

channels_test.go:231–251  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

229}
230
231func TestUnwrap(t *testing.T) {
232 rawChan := make(chan int)
233 ch := NewNativeChannel(5)
234 Unwrap(ch, rawChan)
235
236 for i := 0; i < 5; i++ {
237 ch.In() <- i
238 }
239 ch.Close()
240
241 for i := 0; i < 5; i++ {
242 x := <-rawChan
243 if x != i {
244 t.Error("Unwrapped value", x, "was expecting", i)
245 }
246 }
247 _, ok := <-rawChan
248 if ok {
249 t.Error("Unwrapped channel didn't close")
250 }
251}
252
253func ExampleChannel() {
254 var ch Channel

Callers

nothing calls this directly

Calls 4

InMethod · 0.95
CloseMethod · 0.95
NewNativeChannelFunction · 0.85
UnwrapFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…