github.com/yimialmonte/fabric@v2.1.1+incompatible/common/graph/choose_test.go (about)

     1  /*
     2  Copyright IBM Corp. All Rights Reserved.
     3  
     4  SPDX-License-Identifier: Apache-2.0
     5  */
     6  
     7  package graph
     8  
     9  import (
    10  	"testing"
    11  
    12  	"github.com/stretchr/testify/assert"
    13  )
    14  
    15  func TestCombinationsExceed(t *testing.T) {
    16  	// 20 choose 5 is 15504.
    17  	assert.False(t, CombinationsExceed(20, 5, 15504))
    18  	assert.False(t, CombinationsExceed(20, 5, 15505))
    19  	assert.True(t, CombinationsExceed(20, 5, 15503))
    20  
    21  	// A huge number of combinations doesn't overflow.
    22  	assert.True(t, CombinationsExceed(10000, 500, 9000))
    23  
    24  	// N < K returns false
    25  	assert.False(t, CombinationsExceed(20, 30, 0))
    26  }