Sha256: 3c8ec759a3d23b09a40a3aeecdae4c224608c66e6963d163eb7c27880989e0bf
Contents?: true
Size: 1.79 KB
Versions: 259
Compression:
Stored size: 1.79 KB
Contents
#require 'runtime/interval_skip_list/spec_helper' # #MAX_INTERVAL = 100000 # #describe IntervalSkipList do # describe "#next_node_height" do # attr_reader :list # # before do # @list = IntervalSkipList.new # end # # it "returns a number between 1 and the max_height of the list" do # height = list.next_node_height # height.should be <= list.max_height # height.should be > 0 # end # end # # describe "a list with 1000 random intervals" do # attr_reader :list, :inserted_ranges # # before do # @list = IntervalSkipList.new # @inserted_ranges = [] # # 0.upto(10) do |i| # first, last = [rand(MAX_INTERVAL), rand(MAX_INTERVAL)].sort # range = first..last # list.insert(range, i) # inserted_ranges.push(range) # end # end # # it "functions correctly for stabbing queries" do # 10000.times do # n = rand(MAX_INTERVAL) # ranges = list.containing(n).sort # # expected_ranges = [] # inserted_ranges.each_with_index do |range,i| # expected_ranges.push(i) if n > range.first && n < range.last # end # expected_ranges.sort! # unless ranges == expected_ranges # puts "N = #{n}" # puts "Expected: " + expected_ranges.inspect # puts "Actual: " + ranges.inspect # expected_ranges.size.should be <= ranges.size # puts "Missing containers: #{(expected_ranges.map {|o| o.object_id} - ranges.map {|o| o.object_id}).inspect}" # puts "Unexpected containers: #{(ranges.map {|o| o.object_id} - expected_ranges.map {|o| o.object_id}).inspect}" # puts "Inserted Ranges: #{inserted_ranges.inspect}" # puts "Expected Ranges: #{expected_ranges.map {|i| inserted_ranges[i]}.inspect}" # end # end # end # end #end
Version data entries
259 entries across 214 versions & 32 rubygems