1
1
mirror of https://github.com/walles/moar.git synced 2024-11-26 13:46:16 +03:00

Update tests with new status line format

Line numbers are gone, the tests should reflect that.
This commit is contained in:
Johan Walles 2021-05-22 16:05:06 +02:00
parent 5e09be8a82
commit ac6bdb4dbb
2 changed files with 8 additions and 4 deletions

View File

@ -454,6 +454,10 @@ func (r *Reader) _CreateStatusUnlocked(firstLineOneBased int, lastLineOneBased i
return prefix + "<empty>"
}
if len(r.lines) == 1 {
return prefix + "1 line 100%"
}
percent := int(100 * float64(lastLineOneBased) / float64(len(r.lines)))
return fmt.Sprintf("%s%s lines %d%%",

View File

@ -259,12 +259,12 @@ func testStatusText(t *testing.T, fromLine int, toLine int, totalLines int, expe
}
func TestStatusText(t *testing.T) {
testStatusText(t, 1, 10, 20, "1-10/20 50%")
testStatusText(t, 1, 5, 5, "1-5/5 100%")
testStatusText(t, 998, 999, 1000, "998-999/1_000 99%")
testStatusText(t, 1, 10, 20, "20 lines 50%")
testStatusText(t, 1, 5, 5, "5 lines 100%")
testStatusText(t, 998, 999, 1000, "1_000 lines 99%")
testStatusText(t, 0, 0, 0, "<empty>")
testStatusText(t, 1, 1, 1, "1-1/1 100%")
testStatusText(t, 1, 1, 1, "1 line 100%")
// Test with filename
testMe, err := NewReaderFromFilename(getSamplesDir()+"/empty", *styles.Native, formatters.TTY16m)