git.sr.ht/~pingoo/stdx@v0.0.0-20240218134121-094174641f6e/crypto/rand_test.go (about)

     1  package crypto
     2  
     3  import (
     4  	"testing"
     5  )
     6  
     7  func TestRandBytes(t *testing.T) {
     8  	var n uint64 = 42
     9  
    10  	data, err := RandBytes(n)
    11  	if err != nil {
    12  		t.Error(err)
    13  	}
    14  
    15  	if len(data) != int(n) {
    16  		t.Error("Generated bytes buffer is not at the expected size")
    17  	}
    18  }