-
-
Save alandotcom/3908531 to your computer and use it in GitHub Desktop.
Rspec Binary Search
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require './binary' | |
| describe 'binary_search' do | |
| let(:int_ary) { (100..200).to_a } | |
| let(:strg_ary) { %w{ swedish\ chef miss\ piggy scooter gnu animal foo-foo }.sort } | |
| let(:one_elemnt_ary) { [0] } | |
| it 'returns correct index' do | |
| binary_search(135,int_ary).should eq 35 | |
| binary_search('miss piggy',strg_ary).should eq 3 | |
| binary_search(5,one_elemnt_ary).should eq -1 | |
| binary_search(0,one_elemnt_ary).should eq 0 | |
| binary_search(0,one_elemnt_ary).should eq 0 | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment