Sha256: 6bf46776317d0885a99ecd1236d0d299558d036a2d70e44fac1f6cfe9bf2a0a5
Contents?: true
Size: 1.26 KB
Versions: 15
Compression:
Stored size: 1.26 KB
Contents
require 'spec_helper' describe Metrics::Statistics::UniformSample do before(:each) do end it "should have a size equal to the initialization parameter" do sample = Metrics::Statistics::UniformSample.new(100) sample.size.should == 100 end it "should allocate an array of the requested size" do sample = Metrics::Statistics::UniformSample.new(100) sample.values.length.should == 100 sample.values.each do |value| value.should == 0 end end it "should update at the end of the list" do sample = Metrics::Statistics::UniformSample.new(100) (1..100).each do |i| sample.update(i) end values = sample.values (0..99).each do |index| values[index].should == (index + 1) end end it "should update a random entry in the list when it's full" do sample = Metrics::Statistics::UniformSample.new(100) sample.should_receive(:rand).with(any_args()).and_return(50) (1..101).each do |i| sample.update(i) end values = sample.values (0..49).each do |index| values[index].should == (index + 1) end values[50].should == 101 (51..99).each do |index| values[index].should == (index + 1) end end end
Version data entries
15 entries across 15 versions & 2 rubygems