Skip to content

Commit

Permalink
Add a regression test
Browse files Browse the repository at this point in the history
  • Loading branch information
walles committed Aug 13, 2024
1 parent a67c887 commit c379459
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
18 changes: 18 additions & 0 deletions m/pager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,24 @@ func TestCodeHighlight_compressed(t *testing.T) {
}
}

// Regression test for:
// https://github.com/walles/moar/issues/236#issuecomment-2282677792
//
// Sample file sysctl.h from:
// https://github.com/fastfetch-cli/fastfetch/blob/f9597eba39d6afd278eeca2f2972f73a7e54f111/src/common/sysctl.h
func TestCodeHighlightingIncludes(t *testing.T) {
reader, err := NewReaderFromFilename("../sample-files/sysctl.h", *styles.Get("native"), formatters.TTY16m, nil)
assert.NilError(t, err)
assert.NilError(t, reader._wait())

screen := startPaging(t, reader)
firstIncludeLine := screen.GetRow(2)
secondIncludeLine := screen.GetRow(3)

// Both should start with "#include" colored the same way
assertCellsEqual(t, firstIncludeLine[0], secondIncludeLine[0])
}

func TestUnicodePrivateUse(t *testing.T) {
// This character lives in a Private Use Area:
// https://codepoints.net/U+f244
Expand Down
12 changes: 12 additions & 0 deletions sample-files/sysctl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#pragma once

#include "fastfetch.h"
#include "util/FFcheckmacros.h"

#include <sys/types.h>
#include <sys/sysctl.h>

const char* ffSysctlGetString(const char* propName, FFstrbuf* result);
FF_C_NODISCARD int ffSysctlGetInt(const char* propName, int defaultValue);
FF_C_NODISCARD int64_t ffSysctlGetInt64(const char* propName, int64_t defaultValue);
FF_C_NODISCARD void* ffSysctlGetData(int* request, u_int requestLength, size_t* resultLength);

0 comments on commit c379459

Please sign in to comment.