summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2016-10-13 21:24:47 +0100
committerw0rp <devw0rp@gmail.com>2016-10-13 21:24:47 +0100
commita089fabb5c264026a26f7c63aa6f11c5fa9da30a (patch)
tree721ad6bfcdc5d6d2e01d263ec890c4412da6d2f9 /test
parentf506887b28b64879a8dd7c47ade57164c42e86df (diff)
downloadale-a089fabb5c264026a26f7c63aa6f11c5fa9da30a.zip
Add some unit tests for the BinarySearch function.
Diffstat (limited to 'test')
-rw-r--r--test/test_loclist_binary_search.vader26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/test_loclist_binary_search.vader b/test/test_loclist_binary_search.vader
new file mode 100644
index 00000000..97d8a026
--- /dev/null
+++ b/test/test_loclist_binary_search.vader
@@ -0,0 +1,26 @@
+Before:
+ let g:loclist = [
+ \ {'lnum': 2, 'col': 10},
+ \ {'lnum': 3, 'col': 2},
+ \ {'lnum': 3, 'col': 10},
+ \ {'lnum': 3, 'col': 12},
+ \ {'lnum': 3, 'col': 25},
+ \ {'lnum': 5, 'col': 4},
+ \ {'lnum': 5, 'col': 5},
+ \]
+
+Execute (Exact column matches should be correct):
+ AssertEqual ale#util#BinarySearch(g:loclist, 3, 2), 1
+
+Execute (Off lines, there should be no match):
+ AssertEqual ale#util#BinarySearch(g:loclist, 4, 2), -1
+
+Execute (Near column matches should be taken):
+ AssertEqual ale#util#BinarySearch(g:loclist, 3, 11), 2
+ AssertEqual ale#util#BinarySearch(g:loclist, 3, 13), 4
+
+Execute (Columns before should be taken when the cursor is far ahead):
+ AssertEqual ale#util#BinarySearch(g:loclist, 3, 300), 4
+
+After:
+ unlet g:loclist