(t *testing.T)
| 107 | } |
| 108 | |
| 109 | func TestHashScan(t *testing.T) { |
| 110 | cases := []struct { |
| 111 | encoded interface{} |
| 112 | want Hash |
| 113 | wantErr bool |
| 114 | }{{ |
| 115 | encoded: int64(1), |
| 116 | wantErr: true, |
| 117 | }, { |
| 118 | encoded: []byte("short"), |
| 119 | wantErr: true, |
| 120 | }, { |
| 121 | encoded: mustDecodeHex("0100000000000000000000000000000000000000000000000000000000000000"), |
| 122 | want: NewHash([32]byte{1}), |
| 123 | }} |
| 124 | |
| 125 | for _, c := range cases { |
| 126 | var got Hash |
| 127 | err := got.Scan(c.encoded) |
| 128 | if err != nil && !c.wantErr { |
| 129 | t.Errorf("Scan(%v) error = %v want nil", c.encoded, err) |
| 130 | } |
| 131 | if got != c.want { |
| 132 | t.Errorf("Scan(%v) = %x want %x", c.encoded, got.Bytes(), c.want.Bytes()) |
| 133 | } |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | func TestHashReadFrom(t *testing.T) { |
| 138 | cases := []struct { |
nothing calls this directly
no test coverage detected