(t *testing.T)
| 135 | } |
| 136 | |
| 137 | func TestHashReadFrom(t *testing.T) { |
| 138 | cases := []struct { |
| 139 | buf []byte |
| 140 | want Hash |
| 141 | wantErr bool |
| 142 | }{{ |
| 143 | buf: []byte("short"), |
| 144 | wantErr: true, |
| 145 | }, { |
| 146 | buf: mustDecodeHex("0100000000000000000000000000000000000000000000000000000000000000"), |
| 147 | want: NewHash([32]byte{1}), |
| 148 | }} |
| 149 | |
| 150 | for _, c := range cases { |
| 151 | var buf bytes.Buffer |
| 152 | buf.Write(c.buf[:]) |
| 153 | var got Hash |
| 154 | _, err := got.ReadFrom(&buf) |
| 155 | if err != nil && !c.wantErr { |
| 156 | t.Errorf("ReadFrom(%x) error = %v want nil", c.buf, err) |
| 157 | } |
| 158 | if got != c.want { |
| 159 | t.Errorf("ReadFrom(%x) = %x want %x", c.buf, got.Bytes(), c.want.Bytes()) |
| 160 | } |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | func TestHashIsZero(t *testing.T) { |
| 165 | var hash *Hash |
nothing calls this directly
no test coverage detected