Sha256: 11584b1d016fa7255501c3e9d31ce8b48421cea73b8682e0a913e24fc4c8955c
Contents?: true
Size: 1.62 KB
Versions: 1
Compression:
Stored size: 1.62 KB
Contents
require "spec_helper" require "hamster/vector" describe Hamster::Vector do [:get, :[], :at].each do |method| describe "##{method}" do describe "when empty" do before do @vector = Hamster.vector end it "always returns nil" do (-1..1).each do |i| @vector.send(method, i).should be_nil end end end describe "when not empty" do before do @vector = Hamster.vector(*(1..1025)) end describe "with a positive index" do describe "within the absolute bounds of the vector" do it "returns the value at the specified index from the head" do (0..(@vector.size - 1)).each do |i| @vector.send(method, i).should == i + 1 end end end describe "outside the absolute bounds of the vector" do it "returns nil" do @vector.send(method, @vector.size).should be_nil end end end describe "with a negative index" do describe "within the absolute bounds of the vector" do it "returns the value at the specified index from the tail" do (-@vector.size..-1).each do |i| @vector.send(method, i).should == @vector.size + i + 1 end end end describe "outside the absolute bounds of the vector" do it "returns nil" do @vector.send(method, -@vector.size.next).should be_nil end end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hamster-1.0.1.pre.rc.1 | spec/hamster/vector/get_spec.rb |