github.com/driusan/dgit@v0.0.0-20221118233547-f39f0c15edbb/git/sha1_test.go (about)

     1  package git
     2  
     3  import (
     4  	"testing"
     5  )
     6  
     7  func TestSha1Stringer(t *testing.T) {
     8  	tests := []struct {
     9  		Sha1   Sha1
    10  		String string
    11  	}{
    12  		{
    13  			Sha1{0x37, 0xff, 0x15, 0xce, 0x14, 0x33, 0x8b, 0xca,
    14  				0x67, 0xe8, 0x6a, 0x73, 0x65, 0x05, 0xc5, 0x48, 0x2d,
    15  				0x83, 0x48, 0xaa,
    16  			},
    17  			"37ff15ce14338bca67e86a736505c5482d8348aa",
    18  		},
    19  		{Sha1{}, "0000000000000000000000000000000000000000"},
    20  		{
    21  			Sha1{0x00, 0xff, 0x15, 0xce, 0x14, 0x33, 0x8b, 0xca,
    22  				0x67, 0xe8, 0x6a, 0x73, 0x65, 0x05, 0xc5, 0x48, 0x2d,
    23  				0x83, 0x48, 0xaa,
    24  			},
    25  			"00ff15ce14338bca67e86a736505c5482d8348aa",
    26  		},
    27  	}
    28  	for i, test := range tests {
    29  		if got := test.Sha1.String(); got != test.String {
    30  			t.Errorf("tc %d: got %v want %v", i, got, test.String)
    31  		}
    32  	}
    33  }