1
1
mirror of https://github.com/walles/moar.git synced 2024-07-07 08:36:29 +03:00

Test case for #166

This test reproduces the symptoms of the crash in #166.

Next step is to make it not crash any more.
This commit is contained in:
Johan Walles 2023-12-01 06:57:08 +01:00
parent ddd7aec274
commit abc235fbef
2 changed files with 41 additions and 0 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
/moar
/moar.exe
/releases/moar-*
/m/__debug_bin*

40
m/scrollPosition_test.go Normal file
View File

@ -0,0 +1,40 @@
package m
import (
"strings"
"testing"
"github.com/walles/moar/twin"
"gotest.tools/v3/assert"
)
func TestCanonicalize1000(t *testing.T) {
pager := Pager{}
pager.screen = twin.NewFakeScreen(100, 100)
pager.reader = NewReaderFromText("test", strings.Repeat("a\n", 2000))
pager.ShowStatusBar = true
pager.ShowLineNumbers = true
pager.scrollPosition = newScrollPosition("TestCanonicalize1000")
scrollPosition := scrollPosition{
internalDontTouch: scrollPositionInternal{
lineNumberOneBased: 1000,
deltaScreenLines: 0,
name: "Fake scroll position",
canonicalizing: false,
canonical: scrollPositionCanonical{
width: 0,
height: 0,
showLineNumbers: false,
showStatusBar: false,
wrapLongLines: false,
lineNumberOneBased: 0,
deltaScreenLines: 0,
},
},
}
lineNumberOneBased := scrollPosition.lineNumberOneBased(&pager)
assert.Equal(t, lineNumberOneBased, 1)
}