|
13 | 13 | *******************************************************************************/ |
14 | 14 | package org.eclipse.lsp4e.test.edit; |
15 | 15 |
|
16 | | -import static org.junit.jupiter.api.Assertions.*; |
17 | | -import static org.junit.jupiter.api.Assumptions.*; |
| 16 | +import static org.junit.jupiter.api.Assertions.assertEquals; |
| 17 | +import static org.junit.jupiter.api.Assertions.assertFalse; |
| 18 | +import static org.junit.jupiter.api.Assertions.assertNotEquals; |
| 19 | +import static org.junit.jupiter.api.Assertions.assertNotNull; |
| 20 | +import static org.junit.jupiter.api.Assertions.assertNull; |
| 21 | +import static org.junit.jupiter.api.Assertions.assertTrue; |
18 | 22 |
|
19 | 23 | import java.io.ByteArrayInputStream; |
20 | 24 | import java.io.ByteArrayOutputStream; |
|
31 | 35 | import java.util.List; |
32 | 36 | import java.util.Random; |
33 | 37 | import java.util.UUID; |
| 38 | +import java.util.stream.Stream; |
34 | 39 |
|
35 | 40 | import org.eclipse.core.filesystem.EFS; |
36 | 41 | import org.eclipse.core.resources.IFile; |
|
40 | 45 | import org.eclipse.core.runtime.CoreException; |
41 | 46 | import org.eclipse.core.runtime.IPath; |
42 | 47 | import org.eclipse.core.runtime.NullProgressMonitor; |
| 48 | +import org.eclipse.jdt.annotation.Nullable; |
43 | 49 | import org.eclipse.jface.text.IDocument; |
44 | 50 | import org.eclipse.jface.text.ITextViewer; |
45 | 51 | import org.eclipse.lsp4e.LSPEclipseUtils; |
|
50 | 56 | import org.eclipse.lsp4j.CompletionTriggerKind; |
51 | 57 | import org.eclipse.lsp4j.CreateFile; |
52 | 58 | import org.eclipse.lsp4j.Location; |
| 59 | +import org.eclipse.lsp4j.MarkupContent; |
| 60 | +import org.eclipse.lsp4j.MarkupKind; |
53 | 61 | import org.eclipse.lsp4j.Position; |
54 | 62 | import org.eclipse.lsp4j.Range; |
55 | 63 | import org.eclipse.lsp4j.RenameFile; |
|
71 | 79 | import org.junit.jupiter.api.condition.OS; |
72 | 80 | import org.junit.jupiter.api.extension.RegisterExtension; |
73 | 81 | import org.junit.jupiter.api.io.TempDir; |
| 82 | +import org.junit.jupiter.params.ParameterizedTest; |
| 83 | +import org.junit.jupiter.params.provider.Arguments; |
| 84 | +import org.junit.jupiter.params.provider.MethodSource; |
74 | 85 |
|
75 | 86 | public class LSPEclipseUtilsTest extends AbstractTestWithProject { |
76 | 87 |
|
@@ -612,4 +623,19 @@ public void parseRange_shouldReturnNullRange_NoFragment() { |
612 | 623 | Range actual = LSPEclipseUtils.parseRange("file:///a/b"); |
613 | 624 | assertNull(actual); |
614 | 625 | } |
| 626 | + |
| 627 | + public static Stream<Arguments> getHtmlDocString() { |
| 628 | + return Stream.of( // |
| 629 | + Arguments.of(Either.forLeft(null), null), // |
| 630 | + Arguments.of(Either.forLeft("test"), "<p>test</p>"), // |
| 631 | + Arguments.of(Either.forRight(new MarkupContent(MarkupKind.MARKDOWN, "# hi!")), "<h1>hi!</h1>\n") // |
| 632 | + ); |
| 633 | + } |
| 634 | + |
| 635 | + @ParameterizedTest |
| 636 | + @MethodSource |
| 637 | + void getHtmlDocString(Either<@Nullable String, MarkupContent> arg, String expected) throws Exception { |
| 638 | + assertEquals(expected, LSPEclipseUtils.getHtmlDocString(arg)); |
| 639 | + } |
| 640 | + |
615 | 641 | } |
0 commit comments