MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / TestHashString

Function TestHashString

crypto/hash/hash_test.go:117–143  ·  view source on GitHub ↗

TestHashString tests the stringized output for hashes.

(t *testing.T)

Source from the content-addressed store, hash-verified

115
116// TestHashString tests the stringized output for hashes.
117func TestHashString(t *testing.T) {
118 // Block 100000 hash.
119 wantStr := "000000000003ba27aa200b1cecaad478d2b00432346c3f1f3986da1afd33e506"
120 hash := Hash([HashSize]byte{ // Make go vet happy.
121 0x06, 0xe5, 0x33, 0xfd, 0x1a, 0xda, 0x86, 0x39,
122 0x1f, 0x3f, 0x6c, 0x34, 0x32, 0x04, 0xb0, 0xd2,
123 0x78, 0xd4, 0xaa, 0xec, 0x1c, 0x0b, 0x20, 0xaa,
124 0x27, 0xba, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
125 })
126
127 hashStr := hash.String()
128 if hashStr != wantStr {
129 t.Errorf("string: wrong hash string - got %v, want %v",
130 hashStr, wantStr)
131 }
132 for n := 0; n < 2*HashSize; n++ {
133 var l = HashSize
134 if n < l {
135 l = n
136 }
137 expect := string([]byte(wantStr)[:2*l])
138 actual := hash.Short(n)
139 if expect != actual {
140 t.Errorf("short result mismatched: expect=%s actual=%s", expect, actual)
141 }
142 }
143}
144
145// TestNewHashFromStr executes tests against the NewHashFromStr function.
146func TestNewHashFromStr(t *testing.T) {

Callers

nothing calls this directly

Calls 4

HashTypeAlias · 0.85
ErrorfMethod · 0.80
ShortMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected