Sha256: 352647b42ff1ee1c026d2425c4f680f406ef09a8869a39238a8899e11b7b839e

Contents?: true

Size: 923 Bytes

Versions: 3

Compression:

Stored size: 923 Bytes

Contents

require File.expand_path(File.dirname(__FILE__)) + '/helper'

class TestAccumulator < Test::Unit::TestCase
  
  def test_accumulator_saves_objs
    a = Tracksperanto::Accumulator.new
    values = [3, {:foo => "bar"}, "foo"]
    values.map(&a.method(:push))
    
    assert_equal 3, a.size
    assert_equal values, a.map{|e| e }, "Should return the same elements from the storage"
  end
  
  def test_accumulator_saves_shitload_of_objs
    a = Tracksperanto::Accumulator.new
    50_000.times { a.push("A string" => rand) }
    assert_equal 50_000, a.size
  end
  
  def test_clear_calls_close_on_buffer
    io = Tracksperanto::BufferIO.new
    flexmock(io).should_receive(:close!)
    flexmock(Tracksperanto::BufferIO).should_receive(:new).once.and_return(io)
    
    a = Tracksperanto::Accumulator.new
    40.times { a.push("A string" => rand) }
    assert_equal 40, a.size
    a.clear
    assert_equal 0, a.size
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tracksperanto-2.2.4 test/test_accumulator.rb
tracksperanto-2.2.2 test/test_accumulator.rb
tracksperanto-2.2.0 test/test_accumulator.rb