X-Git-Url: https://code.delx.au/gnu-emacs-elpa/blobdiff_plain/2ee393efc75af116d8679ea37f6f5176429695cc..79dbe65384654386166aa2c10d2ee56469aa3474:/packages/company/company-tests.el diff --git a/packages/company/company-tests.el b/packages/company/company-tests.el index afd415653..0663c71f9 100644 --- a/packages/company/company-tests.el +++ b/packages/company/company-tests.el @@ -398,7 +398,7 @@ (let (this-command) (company-call 'complete)) (company-call 'open-line 1) - (should (eq 2 (overlay-start company-pseudo-tooltip-overlay))))))) + (should (eq 1 (overlay-start company-pseudo-tooltip-overlay))))))) (ert-deftest company-pseudo-tooltip-show () :tags '(interactive) @@ -419,7 +419,7 @@ (should (eq (overlay-get ov 'company-height) company-tooltip-limit)) (should (eq (overlay-get ov 'company-column) col)) (should (string= (overlay-get ov 'company-display) - " 123 \nc 45 c\nddd\n"))))))) + "\n 123 \nc 45 c\nddd\n"))))))) (ert-deftest company-pseudo-tooltip-edit-updates-width () :tags '(interactive) @@ -448,8 +448,10 @@ (let ((company-candidates-length 1) (company-candidates '("123"))) (company-preview-show-at-point (point)) - (let ((ov company-preview-overlay)) - (should (string= (overlay-get ov 'display) "123\n"))))))) + (let* ((ov company-preview-overlay) + (str (overlay-get ov 'after-string))) + (should (string= str "123")) + (should (eq (get-text-property 0 'cursor str) t))))))) (ert-deftest company-pseudo-tooltip-show-with-annotations () :tags '(interactive) @@ -469,7 +471,7 @@ ;; With margins. (should (eq (overlay-get ov 'company-width) 8)) (should (string= (overlay-get ov 'company-display) - " 123(4) \n 45 \n"))))))) + "\n 123(4) \n 45 \n"))))))) (ert-deftest company-pseudo-tooltip-show-with-annotations-right-aligned () :tags '(interactive) @@ -490,7 +492,7 @@ ;; With margins. (should (eq (overlay-get ov 'company-width) 13)) (should (string= (overlay-get ov 'company-display) - " 123 (4) \n 45 \n 67 (891011) \n"))))))) + "\n 123 (4) \n 45 \n 67 (891011) \n"))))))) (ert-deftest company-create-lines-shows-numbers () (let ((company-show-numbers t) @@ -555,8 +557,29 @@ (should (eq 'company-tooltip-selection (get-text-property (1- ww) 'face (car res)))) + ))) -))) +(ert-deftest company-create-lines-clears-out-non-printables () + :tags '(interactive) + (let (company-show-numbers + (company-candidates (list + (decode-coding-string "avalis\351e" 'utf-8) + "avatar")) + (company-candidates-length 2) + (company-backend 'ignore)) + (should (equal '(" avalis‗e " + " avatar ") + (company--create-lines 0 999))))) + +(ert-deftest company-create-lines-handles-multiple-width () + :tags '(interactive) + (let (company-show-numbers + (company-candidates '("蛙蛙蛙蛙" "蛙abc")) + (company-candidates-length 2) + (company-backend 'ignore)) + (should (equal '(" 蛙蛙蛙蛙 " + " 蛙abc ") + (company--create-lines 0 999))))) (ert-deftest company-column-with-composition () :tags '(interactive) @@ -586,6 +609,24 @@ (put-text-property (point-min) (point-max) 'line-prefix " ") (should (= (company--column) 2))))) +(ert-deftest company-column-with-tabs () + :tags '(interactive) + (with-temp-buffer + (save-window-excursion + (set-window-buffer nil (current-buffer)) + (insert "|\t|\t|\t(") + (let ((tab-width 8)) + (should (= (company--column) 25)))))) + +(ert-deftest company-row-with-header-line-format () + :tags '(interactive) + (with-temp-buffer + (save-window-excursion + (set-window-buffer nil (current-buffer)) + (should (= (company--row) 0)) + (setq header-line-format "aaaaaaa") + (should (= (company--row) 0))))) + (ert-deftest company-plainify () (let ((tab-width 8)) (should (equal-including-properties @@ -879,6 +920,19 @@ foo2")) (should (equal "foo(arg0, arg1)" (buffer-string))) (should (looking-at "arg0"))))) +(ert-deftest company-template-c-like-templatify-generics () + (with-temp-buffer + (let ((text "foo(int i, Dict, long l)")) + (insert text) + (company-template-c-like-templatify text) + (should (equal "foo(arg2, arg3, arg4)" (buffer-string))) + (should (looking-at "arg0")) + (should (equal "TKey" (overlay-get (company-template-field-at) 'display))) + (search-forward "arg3") + (forward-char -1) + (should (equal "Dict" + (overlay-get (company-template-field-at) 'display)))))) + ;;; Clang (ert-deftest company-clang-objc-templatify ()