MCPcopy Create free account
hub / github.com/Vespa314/cflow / TestCodeBlockParser

Function TestCodeBlockParser

plugin/gomark/parser/code_block_test.go:12–64  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestCodeBlockParser(t *testing.T) {
13 tests := []struct {
14 text string
15 codeBlock ast.Node
16 }{
17 {
18 text: "```Hello world!```",
19 codeBlock: nil,
20 },
21 {
22 text: "```\nHello\n```",
23 codeBlock: &ast.CodeBlock{
24 Language: "",
25 Content: "Hello",
26 },
27 },
28 {
29 text: "```\nHello world!\n```",
30 codeBlock: &ast.CodeBlock{
31 Language: "",
32 Content: "Hello world!",
33 },
34 },
35 {
36 text: "```java\nHello \n world!\n```",
37 codeBlock: &ast.CodeBlock{
38 Language: "java",
39 Content: "Hello \n world!",
40 },
41 },
42 {
43 text: "```java\nHello \n world!\n```111",
44 codeBlock: nil,
45 },
46 {
47 text: "```java\nHello \n world!\n``` 111",
48 codeBlock: nil,
49 },
50 {
51 text: "```java\nHello \n world!\n```\n123123",
52 codeBlock: &ast.CodeBlock{
53 Language: "java",
54 Content: "Hello \n world!",
55 },
56 },
57 }
58
59 for _, test := range tests {
60 tokens := tokenizer.Tokenize(test.text)
61 node, _ := NewCodeBlockParser().Parse(tokens)
62 require.Equal(t, StringifyNodes([]ast.Node{test.codeBlock}), StringifyNodes([]ast.Node{node}))
63 }
64}

Callers

nothing calls this directly

Calls 4

TokenizeFunction · 0.92
NewCodeBlockParserFunction · 0.85
StringifyNodesFunction · 0.85
ParseMethod · 0.65

Tested by

no test coverage detected