MCPcopy Index your code
hub / github.com/cheat/cheat / TestColorizeDefaultSyntax

Function TestColorizeDefaultSyntax

internal/sheet/colorize_test.go:46–72  ·  view source on GitHub ↗

TestColorizeDefaultSyntax asserts that when no syntax is specified, the default ("bash") is used and produces the same output as an explicit "bash"

(t *testing.T)

Source from the content-addressed store, hash-verified

44// TestColorizeDefaultSyntax asserts that when no syntax is specified, the
45// default ("bash") is used and produces the same output as an explicit "bash"
46func TestColorizeDefaultSyntax(t *testing.T) {
47
48 conf := config.Config{
49 Formatter: "terminal16m",
50 Style: "monokai",
51 }
52
53 // use bash-specific content that tokenizes differently across lexers
54 code := "if [[ -f /etc/passwd ]]; then\n echo \"found\" | grep -o found\nfi"
55
56 // colorize with empty syntax (should default to "bash")
57 noSyntax := Sheet{Text: code}
58 noSyntax.Colorize(conf)
59
60 // colorize with explicit "bash" syntax
61 bashSyntax := Sheet{Text: code, Syntax: "bash"}
62 bashSyntax.Colorize(conf)
63
64 // both should produce the same output
65 if noSyntax.Text != bashSyntax.Text {
66 t.Errorf(
67 "default syntax does not match explicit bash:\ndefault: %q\nexplicit: %q",
68 noSyntax.Text,
69 bashSyntax.Text,
70 )
71 }
72}
73
74// TestColorizeExplicitSyntax asserts that a specified syntax is used
75func TestColorizeExplicitSyntax(t *testing.T) {

Callers

nothing calls this directly

Calls 1

ColorizeMethod · 0.95

Tested by

no test coverage detected