(should (eq t (company--good-prefix-p "abc")))
(should (eq t (company--good-prefix-p '("bar" . t)))))))
+(ert-deftest company-common-with-non-prefix-completion ()
+ (let ((company-backend #'ignore)
+ (company-prefix "abc")
+ company-candidates
+ company-candidates-length
+ company-candidates-cache
+ company-common)
+ (company-update-candidates '("abc" "def-abc"))
+ (should (null company-common))
+ (company-update-candidates '("abc" "abe-c"))
+ (should (null company-common))
+ (company-update-candidates '("abcd" "abcde" "abcdf"))
+ (should (equal "abcd" company-common))))
+
(ert-deftest company-multi-backend-with-lambdas ()
(let ((company-backend
(list (lambda (command &optional arg &rest ignore)
(let* ((ov company-preview-overlay)
(str (overlay-get ov 'after-string)))
(should (string= str "123"))
- (should (eq (get-text-property 0 'cursor str) t)))))))
+ (should (eq (get-text-property 0 'cursor str) 1)))))))
(ert-deftest company-pseudo-tooltip-show-with-annotations ()
:tags '(interactive)
"avatar"))
(company-candidates-length 2)
(company-backend 'ignore))
- (should (equal '(" avalis‗e "
- " avatar ")
+ (should (equal '(" avalis‗e "
+ " avatar ")
(company--create-lines 0 999)))))
(ert-deftest company-create-lines-handles-multiple-width ()
" 蛙abc ")
(company--create-lines 0 999)))))
+(ert-deftest company-create-lines-handles-multiple-width-in-annotation ()
+ (let* (company-show-numbers
+ (alist '(("a" . " ︸") ("b" . " ︸︸")))
+ (company-candidates (mapcar #'car alist))
+ (company-candidates-length 2)
+ (company-backend (lambda (c &optional a)
+ (when (eq c 'annotation)
+ (assoc-default a alist)))))
+ (should (equal '(" a ︸ "
+ " b ︸︸ ")
+ (company--create-lines 0 999)))))
+
(ert-deftest company-column-with-composition ()
:tags '(interactive)
(with-temp-buffer
(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<TKey, TValue>(int i, Dict<TKey, TValue>, long l)"))
+ (insert text)
+ (company-template-c-like-templatify text)
+ (should (equal "foo<arg0, arg1>(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<TKey, TValue>"
+ (overlay-get (company-template-field-at) 'display))))))
+
;;; Clang
(ert-deftest company-clang-objc-templatify ()