processor/processor_test.go GO 157 lines View on github.com → Search inside
1// SPDX-License-Identifier: MIT23package processor45import (6	"strings"7	"testing"8)910func TestProcessConstants(t *testing.T) {11	Trace = true12	ProcessConstants()1314	if len(ExtensionToLanguage) == 0 {15		t.Error("Should not be 0")16	}1718	if len(LanguageFeatures) == 0 {19		t.Error("Should not be 0")20	}21}2223func TestProcessConstantsPathExclude(t *testing.T) {24	PathDenyList = []string{"testing/"}25	ProcessConstants()2627	if PathDenyList[0] != "testing" {28		t.Error("expected / to be trimmed")29	}3031	PathDenyList = []string{}32}3334func TestConfigureGc(t *testing.T) {35	ConfigureGc()36}3738func TestConfigureLazy(t *testing.T) {39	ConfigureLazy(true)40	if !isLazy {41		t.Error("isLazy should be true")42	}4344	ConfigureLazy(false)45	if isLazy {46		t.Error("isLazy should be false")47	}48}4950func TestLoadLanguageFeature(t *testing.T) {51	isLazy = true52	LoadLanguageFeature("Go")53	_, ok := LanguageFeatures["Go"]5455	if !ok {56		t.Error("Language should have been loaded")57	}58}5960func TestLoadLanguageFeatureNew(t *testing.T) {61	isLazy = true62	LanguageFeatures = map[string]LanguageFeature{}63	LoadLanguageFeature("Go")64	LoadLanguageFeature("Go")6566	_, ok := LanguageFeatures["Go"]6768	if !ok {69		t.Error("Language should have been loaded")70	}7172	isLazy = false73	ProcessConstants()74}7576func TestProcessFlags(t *testing.T) {77	Debug = true78	More = true79	Complexity = true8081	processFlags()8283	if Complexity {84		t.Error("Complexity should be false")85	}86}8788func TestPrintLanguages(t *testing.T) {89	result := &strings.Builder{}90	PrintLanguages(result)91	if !strings.Contains(result.String(), "Go Template (tmpl,gohtml,gotxt)\n") {92		t.Fatal("printLanguages test failed")93	}94}9596func TestProcess(t *testing.T) {97	Process()98}99100func TestSetupCountAsLanguage(t *testing.T) {101	ProcessConstants()102	CountAs = "boyter:C Header"103	setupCountAs()104	v := ExtensionToLanguage["boyter"]105106	if v[0] != "C Header" {107		t.Error("Expected boyter to map to C Header")108	}109110	CountAs = ""111}112113func TestSetupCountAsLanguageCase(t *testing.T) {114	ProcessConstants()115	CountAs = "BoYtER:C Header"116	setupCountAs()117	v := ExtensionToLanguage["boyter"]118119	if v[0] != "C Header" {120		t.Error("Expected boyter to map to C Header")121	}122123	CountAs = ""124}125126func TestSetupCountAsExtension(t *testing.T) {127	ProcessConstants()128	CountAs = "boyter:j2"129	setupCountAs()130	v := ExtensionToLanguage["boyter"]131132	if v[0] != "Jinja" {133		t.Error("Expected boyter to map to Jinja")134	}135136	CountAs = ""137}138139func TestSetupCountAsMultiple(t *testing.T) {140	ProcessConstants()141	CountAs = "boyter:j2,retyob:JAVA"142	setupCountAs()143	v := ExtensionToLanguage["boyter"]144145	if v[0] != "Jinja" {146		t.Error("Expected boyter to map to Jinja")147	}148149	v = ExtensionToLanguage["retyob"]150151	if v[0] != "Java" {152		t.Error("Expected retyob to map to Java")153	}154155	CountAs = ""156}

Findings

✓ No findings reported for this file.

Get this view in your editor

Same data, no extra tab — call code_get_file + code_get_findings over MCP from Claude/Cursor/Copilot.