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

Function TestExtractCodeBlock

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

Source from the content-addressed store, hash-verified

273}
274
275func TestExtractCodeBlock(t *testing.T) {
276 tests := []struct {
277 name string
278 input string
279 want string
280 }{
281 {"with language tag", "```go\nfoo\nbar\n```", "foo\nbar"},
282 {"without language tag", "```\nfoo\n```", "foo"},
283 {"with surrounding text", "Here:\n```\ncode\n```\ndone", "code"},
284 {"no code block", "just text", ""},
285 {"empty block", "```\n```", ""},
286 {"opening fence without newline", "```go", ""},
287 {"no closing fence", "```\nfoo\nbar", ""},
288 }
289 for _, tt := range tests {
290 t.Run(tt.name, func(t *testing.T) {
291 got := extractCodeBlock(tt.input)
292 if got != tt.want {
293 t.Errorf("extractCodeBlock() = %q, want %q", got, tt.want)
294 }
295 })
296 }
297}

Callers

nothing calls this directly

Calls 2

extractCodeBlockFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected