Skip to content

Commit

Permalink
Added preliminary interval skip list deletion examples
Browse files Browse the repository at this point in the history
  • Loading branch information
nathansobo committed Jan 22, 2008
1 parent 9673e27 commit 1c158ef
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 6 deletions.
76 changes: 76 additions & 0 deletions spec/runtime/interval_skip_list/delete_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,79 @@ class IntervalSkipList
public :insert_node, :delete_node, :head, :nodes
end

describe IntervalSkipList, " with nodes of height 1, 3, 1, 2, 3" do
attr_reader :list, :node
include IntervalSkipListSpecHelper

before do
@list = IntervalSkipList.new
end

it_should_behave_like "#next_node_height is deterministic"
def expected_node_heights
[1, 3, 1, 2, 3]
end

before do
list.insert(1..3, :b)
list.insert(1..5, :c)
list.insert(1..7, :d)
list.insert(1..9, :a)
end

describe " nodes[0]" do
before do
@node = list.nodes[0]
end

it "has a key of 1 and a height of 1" do
node.key.should == 1
node.height.should == 1
end
end

describe " nodes[1]" do
before do
@node = list.nodes[1]
end

it "has a key of 3 and a height of 3" do
node.key.should == 3
node.height.should == 3
end
end

describe " nodes[2]" do
before do
@node = list.nodes[2]
end

it "has a key of 5 and a height of 1" do
node.key.should == 5
node.height.should == 1
end
end

describe " nodes[3]" do
before do
@node = list.nodes[3]
end

it "has a key of 7 and a height of 2" do
node.key.should == 7
node.height.should == 2
end
end

describe " nodes[4]" do
before do
@node = list.nodes[4]
end

it "has a key of 9 and a height of 3" do
node.key.should == 9
node.height.should == 3
end
end

end
6 changes: 0 additions & 6 deletions spec/runtime/interval_skip_list/insert_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ def expected_node_heights
[1, 3, 2, 3, 1]
end

def confirm_containing_intervals(range, *markers)
(range.begin).upto(range.end) do |i|
list.containing(i).should have_markers(*markers)
end
end

describe ", when :a is inserted on 1..7" do
before do
list.insert(1..7, :a)
Expand Down

0 comments on commit 1c158ef

Please sign in to comment.