package reasoningmode import "testing" func TestParseCommandRecognizesPersistentEnableAliases(t *testing.T) { tests := []string{ "/think", "/think on", "/think start", "/THINK ON", "/开启推理", } for _, input := range tests { t.Run(input, func(t *testing.T) { command, ok := ParseCommand(input) if !ok || command.Kind != CommandEnable || command.Query != "" { t.Fatalf("ParseCommand(%q)=(%+v,%t), want enable", input, command, ok) } }) } } func TestParseCommandRecognizesDisableAliases(t *testing.T) { tests := []string{ "/think off", "/think end", "/THINK OFF", "/关闭推理", "/rag", } for _, input := range tests { t.Run(input, func(t *testing.T) { command, ok := ParseCommand(input) if !ok || command.Kind != CommandDisable || command.Query != "" { t.Fatalf("ParseCommand(%q)=(%+v,%t), want disable", input, command, ok) } }) } } func TestParseCommandRecognizesSingleTurnReasoning(t *testing.T) { command, ok := ParseCommand(" /think 对比 CRA 和 CR 系列 ") if !ok || command.Kind != CommandSingle || command.Query != "对比 CRA 和 CR 系列" { t.Fatalf("command=%+v ok=%t", command, ok) } } func TestParseCommandAcceptsDocumentedOptionalPlusSeparator(t *testing.T) { command, ok := ParseCommand("/think + 分析根因") if !ok || command.Kind != CommandSingle || command.Query != "分析根因" { t.Fatalf("command=%+v ok=%t", command, ok) } } func TestParseCommandRecognizesHelpAliases(t *testing.T) { for _, input := range []string{"/help", "/帮助", "/h", "/H"} { t.Run(input, func(t *testing.T) { command, ok := ParseCommand(input) if !ok || command.Kind != CommandHelp { t.Fatalf("ParseCommand(%q)=(%+v,%t), want help", input, command, ok) } }) } } func TestParseCommandRejectsEmbeddedOrSimilarInputs(t *testing.T) { tests := []string{ "普通问题", "abc /think on", "/thinking", "//think on", } for _, input := range tests { t.Run(input, func(t *testing.T) { if command, ok := ParseCommand(input); ok { t.Fatalf("ParseCommand(%q)=(%+v,true), want no command", input, command) } }) } } func TestParseCommandInterceptsMalformedControlArguments(t *testing.T) { tests := []string{ "/think on 多余内容", "/think off 多余内容", "/think start 多余内容", "/think end 多余内容", "/rag 多余内容", "/开启推理 多余内容", "/关闭推理 多余内容", } for _, input := range tests { t.Run(input, func(t *testing.T) { command, ok := ParseCommand(input) if !ok || command.Kind != CommandInvalid { t.Fatalf("ParseCommand(%q)=(%+v,%t), want invalid command", input, command, ok) } }) } }