-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmarkdown_test.go
More file actions
98 lines (95 loc) · 2.4 KB
/
markdown_test.go
File metadata and controls
98 lines (95 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package main
import (
"testing"
)
func TestConvertMarkdownToMrkdwn(t *testing.T) {
tests := []struct {
name string
markdown string
expected string
}{
{
name: "bold with double asterisks",
markdown: "This is **bold** text",
expected: "This is *bold* text",
},
{
name: "bold with double underscores",
markdown: "This is __bold__ text",
expected: "This is *bold* text",
},
{
name: "strikethrough",
markdown: "This is ~~strikethrough~~ text",
expected: "This is ~strikethrough~ text",
},
{
name: "inline code",
markdown: "This is `code` text",
expected: "This is `code` text",
},
{
name: "link",
markdown: "Check out [Google](https://google.com)",
expected: "Check out <https://google.com|Google>",
},
{
name: "code block with language",
markdown: "```python\nprint('hello')\n```",
expected: "```\nprint('hello')\n```",
},
{
name: "code block without language",
markdown: "```\ncode here\n```",
expected: "```\ncode here\n```",
},
{
name: "unordered list with asterisk",
markdown: "* Item 1\n* Item 2",
expected: "• Item 1\n• Item 2",
},
{
name: "unordered list with dash",
markdown: "- Item 1\n- Item 2",
expected: "• Item 1\n• Item 2",
},
{
name: "ordered list",
markdown: "1. First\n2. Second",
expected: "1. First\n2. Second",
},
{
name: "mixed formatting",
markdown: "This is **bold** and ~~strike~~ with a [link](https://example.com)",
expected: "This is *bold* and ~strike~ with a <https://example.com|link>",
},
{
name: "italic with single asterisk",
markdown: "This is *italic* text",
expected: "This is _italic_ text",
},
{
name: "code block with complex language specifier",
markdown: "```c++\nint main() {}\n```",
expected: "```\nint main() {}\n```",
},
{
name: "code block with c# language",
markdown: "```c#\npublic void Main() {}\n```",
expected: "```\npublic void Main() {}\n```",
},
{
name: "code block with hyphenated language",
markdown: "```objective-c\n@interface MyClass\n```",
expected: "```\n@interface MyClass\n```",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
result := convertMarkdownToMrkdwn(tt.markdown)
if result != tt.expected {
t.Errorf("convertMarkdownToMrkdwn() = %q, want %q", result, tt.expected)
}
})
}
}