ldiff: Len
This commit is contained in:
parent
887354642c
commit
f6e2cc3890
@ -94,6 +94,8 @@ type Diff interface {
|
|||||||
Ids() []string
|
Ids() []string
|
||||||
// Hash returns hash of all elements in the diff
|
// Hash returns hash of all elements in the diff
|
||||||
Hash() string
|
Hash() string
|
||||||
|
// Len returns count of elements in the diff
|
||||||
|
Len() int
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remote interface for using in the Diff
|
// Remote interface for using in the Diff
|
||||||
@ -159,6 +161,12 @@ func (d *diff) Ids() (ids []string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *diff) Len() int {
|
||||||
|
d.mu.RLock()
|
||||||
|
defer d.mu.RUnlock()
|
||||||
|
return d.sl.Len()
|
||||||
|
}
|
||||||
|
|
||||||
func (d *diff) Elements() (elements []Element) {
|
func (d *diff) Elements() (elements []Element) {
|
||||||
d.mu.RLock()
|
d.mu.RLock()
|
||||||
defer d.mu.RUnlock()
|
defer d.mu.RUnlock()
|
||||||
|
|||||||
@ -179,6 +179,7 @@ func TestDiff_Ids(t *testing.T) {
|
|||||||
gotIds := d.Ids()
|
gotIds := d.Ids()
|
||||||
sort.Strings(gotIds)
|
sort.Strings(gotIds)
|
||||||
assert.Equal(t, ids, gotIds)
|
assert.Equal(t, ids, gotIds)
|
||||||
|
assert.Equal(t, len(ids), d.Len())
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDiff_Elements(t *testing.T) {
|
func TestDiff_Elements(t *testing.T) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user