1
1
mirror of https://github.com/walles/moar.git synced 2024-09-11 12:15:43 +03:00

Document assertions

To clarify questions from #163.
This commit is contained in:
Johan Walles 2023-10-14 08:43:18 +02:00
parent 9c2f1ca57f
commit ae34878ee5
2 changed files with 8 additions and 1 deletions

View File

@ -405,8 +405,9 @@ func (screen *UnixScreen) Clear() {
}
// Returns the rendered line, plus how many information carrying cells went into
// it (see headerLength inside of this function).
// it
func renderLine(row []Cell) (string, int) {
// Strip trailing whitespace
lastSignificantCellIndex := len(row) - 1
for ; lastSignificantCellIndex >= 0; lastSignificantCellIndex-- {
lastCell := row[lastSignificantCellIndex]

View File

@ -78,6 +78,9 @@ func TestRenderLineEmpty(t *testing.T) {
rendered, count := renderLine(row)
assert.Equal(t, count, 0)
// All lines are expected to stand on their own, so we always need to clear
// to EOL whether or not the line is empty.
assert.Equal(t, rendered, "\x1b[m\x1b[K")
}
@ -152,6 +155,9 @@ func TestRenderLineOnlyTrailingSpaces(t *testing.T) {
rendered, count := renderLine(row)
assert.Equal(t, count, 0)
// All lines are expected to stand on their own, so we always need to clear
// to EOL whether or not the line is empty.
assert.Equal(t, rendered, "\x1b[m\x1b[K")
}