From 02209f3d1db7b8cd139ea91e3267b0c1da78aa72 Mon Sep 17 00:00:00 2001 From: Johan Walles Date: Sat, 6 Apr 2024 08:32:34 +0200 Subject: [PATCH] Add compressed file highlighting test case For the initial part of . --- m/pager_test.go | 26 ++++++++++++++++++++++++++ sample-files/markdown.md.gz | Bin 0 -> 43 bytes 2 files changed, 26 insertions(+) create mode 100644 sample-files/markdown.md.gz diff --git a/m/pager_test.go b/m/pager_test.go index 5269bef..7a5e9d2 100644 --- a/m/pager_test.go +++ b/m/pager_test.go @@ -193,6 +193,32 @@ func TestCodeHighlighting(t *testing.T) { } } +func TestCodeHighlight_compressed(t *testing.T) { + // Same as TestCodeHighlighting but with "markdown.md.gz" + reader, err := NewReaderFromFilename("../sample-files/markdown.md.gz", *styles.Get("native"), formatters.TTY16m, nil) + assert.NilError(t, err) + assert.NilError(t, reader._wait()) + + markdownHeading1Style := twin.StyleDefault.WithAttr(twin.AttrBold) + var answers = []twin.Cell{ + twin.NewCell('#', markdownHeading1Style), + twin.NewCell(' ', twin.StyleDefault), + twin.NewCell('M', markdownHeading1Style), + twin.NewCell('a', markdownHeading1Style), + twin.NewCell('r', markdownHeading1Style), + twin.NewCell('k', markdownHeading1Style), + twin.NewCell('d', markdownHeading1Style), + twin.NewCell('o', markdownHeading1Style), + twin.NewCell('w', markdownHeading1Style), + twin.NewCell('n', markdownHeading1Style), + } + + contents := startPaging(t, reader).GetRow(0) + for pos, expected := range answers { + assertCellsEqual(t, expected, contents[pos]) + } +} + func TestUnicodePrivateUse(t *testing.T) { // This character lives in a Private Use Area: // https://codepoints.net/U+f244 diff --git a/sample-files/markdown.md.gz b/sample-files/markdown.md.gz new file mode 100644 index 0000000000000000000000000000000000000000..7793b794ce63c7ded67f2e5c8fce4afd5b438113 GIT binary patch literal 43 zcmb2|=HRG*C6LCzoSRsboswUkr literal 0 HcmV?d00001