github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/model/flow/entity_test.go (about)

     1  package flow_test
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/require"
     7  
     8  	"github.com/onflow/flow-go/model/flow"
     9  	"github.com/onflow/flow-go/utils/unittest"
    10  )
    11  
    12  func TestDeduplicate(t *testing.T) {
    13  	require.Nil(t, flow.Deduplicate[*flow.Collection](nil))
    14  
    15  	cols := unittest.CollectionListFixture(5)
    16  	require.Equal(t, cols, flow.Deduplicate(cols))
    17  
    18  	// create duplicates, and validate
    19  	require.Equal(t, cols, flow.Deduplicate[*flow.Collection](append(cols, cols...)))
    20  
    21  	// verify the original order should be preserved
    22  	require.Equal(t, cols, flow.Deduplicate[*flow.Collection](
    23  		append(cols, cols[3], cols[1], cols[4], cols[2], cols[0])))
    24  }