github.com/lzy4123/fabric@v2.1.1+incompatible/gossip/common/common_test.go (about)

     1  /*
     2  Copyright IBM Corp. All Rights Reserved.
     3  
     4  SPDX-License-Identifier: Apache-2.0
     5  */
     6  
     7  package common
     8  
     9  import (
    10  	"testing"
    11  
    12  	"github.com/stretchr/testify/assert"
    13  )
    14  
    15  func TestIsNotSame(t *testing.T) {
    16  	id := PKIidType("1")
    17  	assert.True(t, id.IsNotSameFilter(PKIidType("2")))
    18  	assert.False(t, id.IsNotSameFilter(PKIidType("1")))
    19  	assert.False(t, id.IsNotSameFilter(id))
    20  }
    21  
    22  func TestPKIidTypeStringer(t *testing.T) {
    23  	tests := []struct {
    24  		input    PKIidType
    25  		expected string
    26  	}{
    27  		{nil, "<nil>"},
    28  		{PKIidType{}, ""},
    29  		{PKIidType{0, 1, 2, 3}, "00010203"},
    30  	}
    31  	for _, tt := range tests {
    32  		assert.Equal(t, tt.expected, tt.input.String())
    33  	}
    34  }