MCPcopy Create free account
hub / github.com/alibaba/open-code-review / TestExtractCodeBlock

Function TestExtractCodeBlock

internal/diff/relocation_test.go:196–216  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

194}
195
196func TestExtractCodeBlock(t *testing.T) {
197 tests := []struct {
198 name string
199 input string
200 want string
201 }{
202 {"with language tag", "```go\nfoo\nbar\n```", "foo\nbar"},
203 {"without language tag", "```\nfoo\n```", "foo"},
204 {"with surrounding text", "Here:\n```\ncode\n```\ndone", "code"},
205 {"no code block", "just text", ""},
206 {"empty block", "```\n```", ""},
207 }
208 for _, tt := range tests {
209 t.Run(tt.name, func(t *testing.T) {
210 got := extractCodeBlock(tt.input)
211 if got != tt.want {
212 t.Errorf("extractCodeBlock() = %q, want %q", got, tt.want)
213 }
214 })
215 }
216}

Callers

nothing calls this directly

Calls 2

extractCodeBlockFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected