mirror of
https://github.com/LukeHagar/libopenapi.git
synced 2025-12-10 04:20:24 +00:00
Added GetFullLineCount() to the Rolodex
This commit is contained in:
@@ -626,3 +626,23 @@ func (r *Rolodex) RolodexFileSize() int64 {
|
|||||||
}
|
}
|
||||||
return size
|
return size
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetFullLineCount returns the total number of lines from all files in the Rolodex
|
||||||
|
func (r *Rolodex) GetFullLineCount() int64 {
|
||||||
|
var lineCount int64
|
||||||
|
for _, v := range r.localFS {
|
||||||
|
if lfs, ok := v.(RolodexFS); ok {
|
||||||
|
for _, f := range lfs.GetFiles() {
|
||||||
|
lineCount += int64(strings.Count(f.GetContent(), "\n")) + 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, v := range r.remoteFS {
|
||||||
|
if lfs, ok := v.(RolodexFS); ok {
|
||||||
|
for _, f := range lfs.GetFiles() {
|
||||||
|
lineCount += int64(strings.Count(f.GetContent(), "\n")) + 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return lineCount
|
||||||
|
}
|
||||||
|
|||||||
@@ -1529,6 +1529,9 @@ func TestRolodex_SimpleTest_OneDoc(t *testing.T) {
|
|||||||
assert.Nil(t, rolo.GetRootIndex())
|
assert.Nil(t, rolo.GetRootIndex())
|
||||||
assert.Len(t, rolo.GetIndexes(), 10)
|
assert.Len(t, rolo.GetIndexes(), 10)
|
||||||
|
|
||||||
|
lineCount := rolo.GetFullLineCount()
|
||||||
|
assert.Equal(t, int64(158), lineCount, "total line count in the rolodex is wrong")
|
||||||
|
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Len(t, rolo.indexes, 10)
|
assert.Len(t, rolo.indexes, 10)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user