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