github.com/grailbio/bigslice@v0.0.0-20230519005545-30c4c12152ad/reshard_test.go (about)

     1  // Copyright 2019 GRAIL, Inc. All rights reserved.
     2  // Use of this source code is governed by the Apache 2.0
     3  // license that can be found in the LICENSE file.
     4  
     5  package bigslice_test
     6  
     7  import (
     8  	"fmt"
     9  	"testing"
    10  
    11  	"github.com/grailbio/bigslice"
    12  )
    13  
    14  func TestReshard(t *testing.T) {
    15  	const N = 1000
    16  	ints := make([]string, N)
    17  	for i := range ints {
    18  		ints[i] = fmt.Sprint(i)
    19  	}
    20  	sharding := []int{1, 2, 5, 10, 100}
    21  	for _, source := range sharding {
    22  		for _, dest := range sharding {
    23  			slice := bigslice.Const(source, ints)
    24  			slice = bigslice.Reshard(slice, dest)
    25  			assertEqual(t, slice, true, ints)
    26  		}
    27  	}
    28  }