Created
May 20, 2018 05:55
-
-
Save sulmanweb/3aaf780aadd516bbe501e6ff07391c4e to your computer and use it in GitHub Desktop.
Find fixed point algorithm spec file
This file contains 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
RSpec.describe BinarySearch, "#find_fixed_point" do | |
context "should have a sorted array" do | |
it "searches for the fixed point" do | |
binary_search = BinarySearch.new | |
expect(binary_search.find_fixed_point([0, 2, 3, 4, 5, 6, 7, 8])).to eql 0 | |
expect(binary_search.find_fixed_point([0, 1, 2, 4, 5, 6, 7, 8])).to eql 2 | |
end | |
it "returns -1 if not found" do | |
binary_search = BinarySearch.new | |
expect(binary_search.find_fixed_point([1, 2, 3, 4, 5, 6, 7, 8])).to eql -1 | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment