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

Function TestExtractCodeBlock

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 2

extractCodeBlockFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected