File: black_hole_test.go

package info (click to toggle)
golang-gopkg-eapache-channels.v1 1.1.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bookworm-backports, experimental, forky, sid, trixie
  • size: 164 kB
  • sloc: makefile: 2
file content (26 lines) | stat: -rw-r--r-- 410 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package channels

import "testing"

func TestBlackHole(t *testing.T) {
	discard := NewBlackHole()

	for i := 0; i < 1000; i++ {
		discard.In() <- i
	}

	discard.Close()

	if discard.Len() != 1000 {
		t.Error("blackhole expected 1000 was", discard.Len())
	}

	// no asserts here, this is just for the race detector's benefit
	ch := NewBlackHole()
	go ch.Len()
	go ch.Cap()

	go func() {
		ch.In() <- nil
	}()
}