github.com/cosmos/cosmos-sdk@v0.50.10/types/coin_internal_test.go (about)

     1  package types
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/suite"
     7  
     8  	"cosmossdk.io/math"
     9  )
    10  
    11  func TestCoinTestSuite(t *testing.T) {
    12  	suite.Run(t, new(coinInternalSuite))
    13  }
    14  
    15  type coinInternalSuite struct {
    16  	suite.Suite
    17  }
    18  
    19  func (s *coinInternalSuite) TestIsSorted() {
    20  	v := math.NewInt(1)
    21  	cases := []struct {
    22  		coins    Coins
    23  		expected bool
    24  	}{
    25  		{Coins{}, true},
    26  		{Coins{{"1", v}}, true},
    27  		{Coins{{"1", v}, {"1", v}}, true},
    28  		{Coins{{"1", v}, {"2", v}}, true},
    29  		{Coins{{"1", v}, {"2", v}, {"2", v}}, true},
    30  
    31  		{Coins{{"1", v}, {"0", v}}, false},
    32  		{Coins{{"1", v}, {"0", v}, {"2", v}}, false},
    33  		{Coins{{"1", v}, {"1", v}, {"0", v}}, false},
    34  	}
    35  	assert := s.Assert()
    36  	for i, tc := range cases {
    37  		assert.Equal(tc.expected, tc.coins.isSorted(), "testcase %d failed", i)
    38  	}
    39  }