github.com/MetalBlockchain/metalgo@v1.11.9/vms/avm/genesis_test.go (about)

     1  // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved.
     2  // See the file LICENSE for licensing terms.
     3  
     4  package avm
     5  
     6  import (
     7  	"fmt"
     8  	"testing"
     9  
    10  	"github.com/stretchr/testify/require"
    11  )
    12  
    13  func TestGenesisAssetCompare(t *testing.T) {
    14  	tests := []struct {
    15  		a        *GenesisAsset
    16  		b        *GenesisAsset
    17  		expected int
    18  	}{
    19  		{
    20  			a:        &GenesisAsset{},
    21  			b:        &GenesisAsset{},
    22  			expected: 0,
    23  		},
    24  		{
    25  			a: &GenesisAsset{
    26  				Alias: "a",
    27  			},
    28  			b: &GenesisAsset{
    29  				Alias: "aa",
    30  			},
    31  			expected: -1,
    32  		},
    33  	}
    34  	for _, test := range tests {
    35  		t.Run(fmt.Sprintf("%s_%s_%d", test.a.Alias, test.b.Alias, test.expected), func(t *testing.T) {
    36  			require := require.New(t)
    37  
    38  			require.Equal(test.expected, test.a.Compare(test.b))
    39  			require.Equal(-test.expected, test.b.Compare(test.a))
    40  		})
    41  	}
    42  }