mirror of https://github.com/perkeep/perkeep.git
put SizedBlobRef String method on the value
Change-Id: Ibfefbc3d21bf4f0cdf7ef729982a02478416802b
This commit is contained in:
parent
42792ccaa0
commit
8b758385d5
|
@ -66,8 +66,8 @@ func (sb *SizedBlobRef) Equal(o SizedBlobRef) bool {
|
|||
return sb.Size == o.Size && sb.BlobRef.String() == o.BlobRef.String()
|
||||
}
|
||||
|
||||
func (sb *SizedBlobRef) String() string {
|
||||
return fmt.Sprintf("[%s %d bytes]", sb.BlobRef.String(), sb.Size)
|
||||
func (sb SizedBlobRef) String() string {
|
||||
return fmt.Sprintf("[%s; %d bytes]", sb.BlobRef.String(), sb.Size)
|
||||
}
|
||||
|
||||
type ReadSeekCloser interface {
|
||||
|
|
|
@ -18,9 +18,11 @@ package blobref
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"gob"
|
||||
"json"
|
||||
"testing"
|
||||
|
||||
. "camli/test/asserts"
|
||||
)
|
||||
|
||||
|
@ -120,3 +122,32 @@ func TestGobbing(t *testing.T) {
|
|||
t.Errorf("got = %q, want %q", &got, br)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBlobRefString(t *testing.T) {
|
||||
bp := MustParse("abc-123")
|
||||
e := "abc-123"
|
||||
if g := bp.String(); g != e {
|
||||
t.Errorf("(&BlobRef).String() = %q, want %q", g, e)
|
||||
}
|
||||
if g := fmt.Sprintf("%s", bp); g != e {
|
||||
t.Errorf("fmt %%s &BlobRef = %q, want %q", g, e)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSizedBlobRefString(t *testing.T) {
|
||||
sbv := SizedBlobRef{BlobRef: MustParse("abc-123"), Size: 456}
|
||||
sbp := &sbv
|
||||
e := "[abc-123; 456 bytes]"
|
||||
if g := sbv.String(); g != e {
|
||||
t.Errorf("SizedBlobRef.String() = %q, want %q", g, e)
|
||||
}
|
||||
if g := sbp.String(); g != e {
|
||||
t.Errorf("(&SizedBlobRef).String() = %q, want %q", g, e)
|
||||
}
|
||||
if g := fmt.Sprintf("%s", sbv); g != e {
|
||||
t.Errorf("fmt %%s SizedBlobRef = %q, want %q", g, e)
|
||||
}
|
||||
if g := fmt.Sprintf("%s", sbp); g != e {
|
||||
t.Errorf("fmt %%s &SizedBlobRef = %q, want %q", g, e)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue