(t *testing.T)
| 10 | ) |
| 11 | |
| 12 | func 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 | } |
nothing calls this directly
no test coverage detected