summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2014-06-26 19:40:29 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2014-06-26 19:40:29 +0900
commit72ec0a34082c3f7b1c87653e2a7b8878bb33ce1d (patch)
treec6e9dd7cfb5aa7961abde9d92a5e3de40fac39f5 /test
parent05118cc440979f40a34bd64e8aef072cf2d627ac (diff)
Add test cases for result scroll
Diffstat (limited to 'test')
-rw-r--r--test/test_fzf.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/test_fzf.rb b/test/test_fzf.rb
index e562f341..a67ebd5a 100644
--- a/test/test_fzf.rb
+++ b/test/test_fzf.rb
@@ -648,5 +648,39 @@ class TestFZF < MiniTest::Unit::TestCase
['1 3 4 2', [[0, 24], [12, 17]]],
], FZF.sort(FZF::ExtendedFuzzyMatcher.new(nil).match(list, '12 34', '', ''))
end
+
+ def test_constrain
+ fzf = FZF.new []
+
+ # [#**** ]
+ assert_equal [false, 0, 0], fzf.constrain(0, 0, 5, 100)
+
+ # *****[**#** ... ] => [**#******* ... ]
+ assert_equal [true, 0, 2], fzf.constrain(5, 7, 10, 100)
+
+ # [**********]**#** => ***[*********#]**
+ assert_equal [true, 3, 12], fzf.constrain(0, 12, 15, 10)
+
+ # *****[**#** ] => ***[**#****]
+ assert_equal [true, 3, 5], fzf.constrain(5, 7, 10, 7)
+
+ # *****[**#** ] => ****[**#***]
+ assert_equal [true, 4, 6], fzf.constrain(5, 7, 10, 6)
+
+ # ***** [#] => ****[#]
+ assert_equal [true, 4, 4], fzf.constrain(10, 10, 5, 1)
+
+ # [ ] #**** => [#]****
+ assert_equal [true, 0, 0], fzf.constrain(-5, 0, 5, 1)
+
+ # [ ] **#** => **[#]**
+ assert_equal [true, 2, 2], fzf.constrain(-5, 2, 5, 1)
+
+ # [***** #] => [****# ]
+ assert_equal [true, 0, 4], fzf.constrain(0, 7, 5, 10)
+
+ # **[***** #] => [******# ]
+ assert_equal [true, 0, 6], fzf.constrain(2, 10, 7, 10)
+ end
end