github.com/outcaste-io/ristretto@v0.2.3/z/simd/add_test.go (about)

     1  package simd
     2  
     3  import (
     4  	"math"
     5  	"testing"
     6  
     7  	"github.com/stretchr/testify/require"
     8  )
     9  
    10  func TestSearch(t *testing.T) {
    11  	keys := make([]uint64, 512)
    12  	for i := 0; i < len(keys); i += 2 {
    13  		keys[i] = uint64(i)
    14  		keys[i+1] = 1
    15  	}
    16  
    17  	for i := 0; i < len(keys); i++ {
    18  		idx := int(Search(keys, uint64(i)))
    19  		require.Equal(t, (i+1)/2, idx, "%v\n%v", i, keys)
    20  	}
    21  	require.Equal(t, 256, int(Search(keys, math.MaxInt64>>1)))
    22  	require.Equal(t, 256, int(Search(keys, math.MaxInt64)))
    23  }