github.com/Finschia/finschia-sdk@v0.48.1/types/coin_internal_test.go (about)

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