github.com/cilium/ebpf@v0.15.1-0.20240517100537-8079b37aa138/internal/io_test.go (about) 1 package internal 2 3 import ( 4 "bytes" 5 "io" 6 "testing" 7 ) 8 9 func TestDiscardZero(t *testing.T) { 10 _, err := io.Copy(DiscardZeroes{}, bytes.NewReader([]byte{0, 0, 0})) 11 if err != nil { 12 t.Error("Returned an error even though input was zero:", err) 13 } 14 15 _, err = io.Copy(DiscardZeroes{}, bytes.NewReader([]byte{1})) 16 if err == nil { 17 t.Error("No error even though input is non-zero") 18 } 19 }