github.com/cloudflare/circl@v1.5.0/sign/internal/dilithium/pack_test.go (about)

     1  package dilithium
     2  
     3  import "testing"
     4  
     5  func TestPackLe16AgainstGeneric(t *testing.T) {
     6  	var p Poly
     7  	var buf1, buf2 [PolyLe16Size]byte
     8  
     9  	for j := 0; j < 1000; j++ {
    10  		pp := randSliceUint32WithMax(N, 16)
    11  		copy(p[:], pp)
    12  		p.PackLe16(buf1[:])
    13  		p.packLe16Generic(buf2[:])
    14  		if buf1 != buf2 {
    15  			t.Fatal()
    16  		}
    17  	}
    18  }
    19  
    20  func BenchmarkPackLe16(b *testing.B) {
    21  	var p Poly
    22  	var buf [PolyLe16Size]byte
    23  	for i := 0; i < b.N; i++ {
    24  		p.PackLe16(buf[:])
    25  	}
    26  }
    27  
    28  func BenchmarkPackLe16Generic(b *testing.B) {
    29  	var p Poly
    30  	var buf [PolyLe16Size]byte
    31  	for i := 0; i < b.N; i++ {
    32  		p.packLe16Generic(buf[:])
    33  	}
    34  }