-
Notifications
You must be signed in to change notification settings - Fork 275
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve lsp hover definition comment formatting
- Loading branch information
1 parent
d5bf43c
commit 20f7a11
Showing
2 changed files
with
94 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package buflsp | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func Test_formatComment(t *testing.T) { | ||
t.Parallel() | ||
|
||
tests := []struct { | ||
name string | ||
input string | ||
expected string | ||
}{ | ||
{ | ||
name: "Single-line comment", | ||
input: "// This is a single-line comment", | ||
expected: " This is a single-line comment", | ||
}, | ||
{ | ||
name: "Multi-line comment", | ||
input: "/*\n This is a\n multi-line comment\n */", | ||
expected: "This is a\nmulti-line comment", | ||
}, | ||
{ | ||
name: "Multi-line comment with mixed indentation", | ||
input: "/*\n * First line\n * - Second line\n * - Third line\n */", | ||
expected: "First line\n- Second line\n - Third line", | ||
}, | ||
{ | ||
name: "Multi-line comment with JavaDoc convention", | ||
input: "/** This is a\n * multi-line comment\n * with multi-asterisks */", | ||
expected: "This is a\nmulti-line comment\nwith multi-asterisks", | ||
}, | ||
{ | ||
name: "Single-line multi-line comment", | ||
input: "/* Single-line multi-line comment */", | ||
expected: "Single-line multi-line comment", | ||
}, | ||
{ | ||
name: "Empty comment", | ||
input: "/**/", | ||
expected: "", | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
t.Parallel() | ||
result := formatComment(tt.input) | ||
if result != tt.expected { | ||
assert.Equal(t, tt.input, result) | ||
} | ||
}) | ||
} | ||
} |