Skip to content

Commit

Permalink
Fix for #22
Browse files Browse the repository at this point in the history
* Signed-off-by: ffrances <ffrances@pontos-deb.gaea>

* added test for duplicates.
  • Loading branch information
fredericfrances authored and randomphrase committed Aug 14, 2018
1 parent e959d43 commit 4133119
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
3 changes: 2 additions & 1 deletion company-c-headers.el
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

(require 'company)
(require 'rx)
(require 'cl)
(require 'cl-lib)

(defgroup company-c-headers nil
Expand Down Expand Up @@ -143,7 +144,7 @@ Filters on the appropriate regex for the current major mode."
(setq next nil)
tmp)))
)
candidates
(remove-duplicates candidates :test 'equal)
))

(defun company-c-headers--meta (candidate)
Expand Down
24 changes: 24 additions & 0 deletions test/company-c-headers-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,30 @@
(should (equal (company-c-headers 'candidates "<sub/") '("<sub/sub.h")))
)))

(ert-deftest subdir-candidates-path-system-duplicates ()
"Test that duplicates proposal are removed system paths."

(with-test-headers
tmpdir '("first.h" "second.h")

(with-test-c-buffer
(setq company-c-headers-path-system (list tmpdir tmpdir))
(setq company-c-headers-path-user (list "foo" "bar"))
(should (equal (company-c-headers 'candidates "\"firs") '("\"first.h")))
)))

(ert-deftest subdir-candidates-path-user-duplicates ()
"Test that duplicates proposal are removed when present user paths."

(with-test-headers
tmpdir '("first.h" "second.h")

(with-test-c-buffer
(setq company-c-headers-path-system (list "foo" "bar"))
(setq company-c-headers-path-user (list tmpdir tmpdir))
(should (equal (company-c-headers 'candidates "\"firs") '("\"first.h")))
)))

(ert-deftest path-bound-to-function ()
"Tests that include paths can be provided by a function"

Expand Down

0 comments on commit 4133119

Please sign in to comment.