Skip to content

Commit c410674

Browse files
committed
test lsp-sonarlint--add-inline-messages
1 parent f5e222a commit c410674

File tree

1 file changed

+88
-4
lines changed

1 file changed

+88
-4
lines changed

test/lsp-sonarlint-secondary-locations-test.el

Lines changed: 88 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,6 @@ SonarLint LSP server."
164164
(save-excursion
165165
(goto-char (point-min))
166166
(forward-line (- line 1))
167-
(message "addding overlay from %s to %s"
168-
(+ from (line-beginning-position))
169-
(+ to (line-beginning-position)))
170167
(make-overlay (+ from (line-beginning-position))
171168
(+ to (line-beginning-position))
172169
(current-buffer)))))
@@ -292,7 +289,6 @@ int divide_seventeen(int param) {
292289
" ^^^^^^^^^^ "))))
293290
(command (lsp-sonarlint-test--secloc-command
294291
primary-loc (list flow))))
295-
(message "cmd : %s" command)
296292
(lsp-sonarlint--show-all-locations command)))
297293
(with-current-buffer lsp-sonarlint--secondary-messages-buffer-name
298294
(should (equal (lsp-sonarlint-test--buf-string-with-overlay-strings)
@@ -324,5 +320,93 @@ int divide_seventeen(int param) {
324320
}
325321
")))))
326322

323+
(ert-deftest lsp-sonarlint-test--add-inline-messages-deduplicate ()
324+
"`lsp-sonarlint--add-inline-messages' deduplicates messages."
325+
(with-temp-buffer
326+
(insert "
327+
Some long line with words clearly separated
328+
")
329+
(let ((locations
330+
(list
331+
`(:message "first"
332+
:overlay ,(lsp-sonarlint-test--place-overlay
333+
"Some long line with words clearly separated"
334+
"^^^^ "))
335+
`(:message "first"
336+
:overlay ,(lsp-sonarlint-test--place-overlay
337+
"Some long line with words clearly separated"
338+
"^^^^ ")))))
339+
(unwind-protect
340+
(progn
341+
(lsp-sonarlint--add-inline-messages locations)
342+
(should (equal (lsp-sonarlint-test--buf-string-with-overlay-strings)
343+
"
344+
first
345+
Some long line with words clearly separated
346+
")))
347+
(remove-overlays)))))
348+
349+
(ert-deftest lsp-sonarlint-test--add-inline-messages-both-sides ()
350+
"`lsp-sonarlint--add-inline-messages' places messages on both sides of a line."
351+
(with-temp-buffer
352+
(insert "
353+
Some long line with words clearly separated
354+
")
355+
(let ((locations
356+
(list
357+
`(:message "first"
358+
:overlay ,(lsp-sonarlint-test--place-overlay
359+
"Some long line with words clearly separated"
360+
"^^^^ "))
361+
`(:message "second"
362+
:overlay ,(lsp-sonarlint-test--place-overlay
363+
"Some long line with words clearly separated"
364+
"^^^^ ")))))
365+
(unwind-protect
366+
(progn
367+
(lsp-sonarlint--add-inline-messages locations)
368+
(should (equal (lsp-sonarlint-test--buf-string-with-overlay-strings)
369+
"
370+
second
371+
Some long line with words clearly separated
372+
first
373+
")))
374+
(remove-overlays)))))
375+
376+
(ert-deftest lsp-sonarlint-test--add-inline-messages-combine ()
377+
"`lsp-sonarlint--add-inline-messages' combines messages pairwise."
378+
(with-temp-buffer
379+
(insert "
380+
Some long line with words clearly separated
381+
")
382+
(let ((locations
383+
(list
384+
`(:message "first"
385+
:overlay ,(lsp-sonarlint-test--place-overlay
386+
"Some long line with words clearly separated"
387+
"^^^^ "))
388+
`(:message "second"
389+
:overlay ,(lsp-sonarlint-test--place-overlay
390+
"Some long line with words clearly separated"
391+
" ^^^^^^^ "))
392+
`(:message "third"
393+
:overlay ,(lsp-sonarlint-test--place-overlay
394+
"Some long line with words clearly separated"
395+
" ^^^^ "))
396+
`(:message "fourth"
397+
:overlay ,(lsp-sonarlint-test--place-overlay
398+
"Some long line with words clearly separated"
399+
" ^ ")))))
400+
(unwind-protect
401+
(progn
402+
(lsp-sonarlint--add-inline-messages locations)
403+
(should (equal (lsp-sonarlint-test--buf-string-with-overlay-strings)
404+
"
405+
first fourth
406+
Some long line with words clearly separated
407+
third second
408+
")))
409+
(remove-overlays)))))
410+
327411

328412
;;; lsp-sonarlint-secondar-locations-test.el ends here

0 commit comments

Comments
 (0)