Skip to content

Commit bf8e86f

Browse files
add encoding and decoding tests
1 parent 5c31366 commit bf8e86f

File tree

2 files changed

+48
-2
lines changed

2 files changed

+48
-2
lines changed

Sources/LanguageServerProtocol/Requests/DoccDocumentationRequest.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,13 @@ public struct DoccDocumentationRequest: TextDocumentRequest, Hashable {
3838
/// The document location at which to lookup symbol information.
3939
public var position: Position?
4040

41-
public init(textDocument: TextDocumentIdentifier, position: Position?) {
41+
public init(textDocument: TextDocumentIdentifier, position: Position? = nil) {
4242
self.textDocument = textDocument
4343
self.position = position
4444
}
4545
}
4646

47-
public struct DoccDocumentationResponse: ResponseType {
47+
public struct DoccDocumentationResponse: ResponseType, Equatable {
4848
public var renderNode: String
4949

5050
public init(renderNode: String) {

Tests/LanguageServerProtocolTests/CodingTests.swift

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,6 +1034,52 @@ final class CodingTests: XCTestCase {
10341034
)
10351035
}
10361036

1037+
func testDoccDocumentationRequest() throws {
1038+
checkDecoding(
1039+
json: #"""
1040+
{
1041+
"textDocument" : {
1042+
"uri" : "file:\/\/\/some\/path"
1043+
}
1044+
}
1045+
"""#,
1046+
expected: DoccDocumentationRequest(
1047+
textDocument: TextDocumentIdentifier(try DocumentURI(string: "file:///some/path"))
1048+
)
1049+
)
1050+
1051+
checkDecoding(
1052+
json: #"""
1053+
{
1054+
"position" : {
1055+
"character" : 17,
1056+
"line" : 4
1057+
},
1058+
"textDocument" : {
1059+
"uri" : "file:\/\/\/some\/path"
1060+
}
1061+
}
1062+
"""#,
1063+
expected: DoccDocumentationRequest(
1064+
textDocument: TextDocumentIdentifier(try DocumentURI(string: "file:///some/path")),
1065+
position: Position(line: 4, utf16index: 17)
1066+
),
1067+
)
1068+
}
1069+
1070+
func testDoccDocumentationResponse() throws {
1071+
checkCoding(
1072+
DoccDocumentationResponse(
1073+
renderNode: "render node contents"
1074+
),
1075+
json: #"""
1076+
{
1077+
"renderNode" : "render node contents"
1078+
}
1079+
"""#
1080+
)
1081+
}
1082+
10371083
func testWorkspaceDocumentDiagnosticReport() throws {
10381084
checkCoding(
10391085
WorkspaceDocumentDiagnosticReport.full(

0 commit comments

Comments
 (0)