(t *testing.T)
| 57 | } |
| 58 | |
| 59 | func TestParse(t *testing.T) { |
| 60 | for _, tt := range parseTests { |
| 61 | fn := tt.fn |
| 62 | if fn == "" { |
| 63 | fn = "Parse" |
| 64 | } |
| 65 | r, ok := parseFn[fn](tt.in) |
| 66 | if r.Valid() != ok { |
| 67 | t.Errorf("Valid != ok for %q", tt.in) |
| 68 | } |
| 69 | if ok && tt.bad { |
| 70 | t.Errorf("%s(%q) didn't fail. It should've.", fn, tt.in) |
| 71 | continue |
| 72 | } |
| 73 | if !ok { |
| 74 | if !tt.bad { |
| 75 | t.Errorf("%s(%q) failed to parse", fn, tt.in) |
| 76 | continue |
| 77 | } |
| 78 | continue |
| 79 | } |
| 80 | if !tt.skipBytes { |
| 81 | r2, ok := ParseBytes([]byte(tt.in)) |
| 82 | if r != r2 { |
| 83 | t.Errorf("ParseBytes(%q) = %v, %v; want %v", tt.in, r2, ok, r) |
| 84 | } |
| 85 | } |
| 86 | str := r.String() |
| 87 | if str != tt.in { |
| 88 | t.Errorf("Parsed %q but String() value differs: %q", tt.in, str) |
| 89 | } |
| 90 | wantDig := str[strings.Index(str, "-")+1:] |
| 91 | if dig := r.Digest(); dig != wantDig { |
| 92 | t.Errorf("Digest(%q) = %q; want %q", tt.in, dig, wantDig) |
| 93 | } |
| 94 | _ = r == r // test that concrete type of r supports equality |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | func TestEquality(t *testing.T) { |
| 99 | in := "sha1-0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33" |
nothing calls this directly
no test coverage detected