3
describe Parslet::Source::RangeSearch do
4
describe "<- #lbound" do
5
context "for a simple array" do
6
let(:ary) { [10, 20, 30, 40, 50] }
7
before(:each) { ary.extend Parslet::Source::RangeSearch }
9
it "should return correct answers for numbers not in the array" do
10
ary.lbound(5).should == 0
11
ary.lbound(15).should == 1
12
ary.lbound(25).should == 2
13
ary.lbound(35).should == 3
14
ary.lbound(45).should == 4
16
it "should return correct answers for numbers in the array" do
17
ary.lbound(10).should == 1
18
ary.lbound(20).should == 2
19
ary.lbound(30).should == 3
20
ary.lbound(40).should == 4
22
it "should cover right edge case" do
23
ary.lbound(50).should be_nil
24
ary.lbound(51).should be_nil
26
it "should cover left edge case" do
27
ary.lbound(0).should == 0
30
context "for an empty array" do
32
before(:each) { ary.extend Parslet::Source::RangeSearch }
34
it "should return nil" do
35
ary.lbound(1).should be_nil
b'\\ No newline at end of file'