github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/builtins/pipes/null/null_test.go (about)

     1  package null_test
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/lmorg/murex/builtins/pipes/null"
     7  	"github.com/lmorg/murex/test/count"
     8  )
     9  
    10  func TestNull(t *testing.T) {
    11  	count.Tests(t, 5)
    12  
    13  	n := new(null.Null)
    14  
    15  	n.Open()
    16  
    17  	i, err := n.Writeln([]byte("foobar"))
    18  	if i != 6 {
    19  		t.Errorf("i should be 6: %d", i)
    20  	}
    21  	if err != nil {
    22  		t.Errorf(err.Error())
    23  	}
    24  
    25  	b, err := n.ReadAll()
    26  	if err != nil {
    27  		t.Errorf(err.Error())
    28  	}
    29  	if len(b) > 0 {
    30  		t.Errorf("ReadAll should be empty: %s", string(b))
    31  	}
    32  	if b == nil {
    33  		t.Error("b == nil. It should be an empty slice")
    34  	}
    35  
    36  	n.Close()
    37  }