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

Add a regression test

For: https://github.com/walles/moar/issues/236#issuecomment-2282677792
This commit is contained in:
Johan Walles 2024-08-13 06:56:16 +02:00
parent a67c887554
commit c379459982
2 changed files with 30 additions and 0 deletions

View File

@ -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

12
sample-files/sysctl.h Normal file
View File

@ -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);