Sha256: 3176f578728dfec1c2bbee36597eb333e1d409c6d3ce01fef9c7e75723417a5b

Contents?: true

Size: 897 Bytes

Versions: 12

Compression:

Stored size: 897 Bytes

Contents

# -*- encoding : utf-8 -*-
require File.expand_path(File.dirname(__FILE__)) + '/helper'

class TestBufferIO < Test::Unit::TestCase
  
  def test_write_in_mem_has_a_stringio
    io = Tracksperanto::BufferIO.new
    9000.times { io.write("a") }
    assert_kind_of StringIO, io.backing_buffer
    assert_nothing_raised { io.close! }
  end
  
  def test_write_larger_than_max_swaps_tempfile
    io = Tracksperanto::BufferIO.new
    io.write("a" * 6_000_001)
    f = io.backing_buffer
    assert_kind_of Tempfile, f
    f.rewind
    assert_equal 6_000_001, f.read.length
    flexmock(f).should_receive(:close!).once
    io.close!
  end
  
  def test_to_file_forces_immediate_promotion_to_file
    io = Tracksperanto::BufferIO.new
    io.write("a" * 3000)
    assert_equal 3000, io.pos
    assert !io.file_backed?
    
    f = io.to_file
    assert_equal 3000, f.pos
    assert f.file_backed?
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
tracksperanto-3.5.9 test/test_buffer_io.rb
tracksperanto-3.5.8 test/test_buffer_io.rb
tracksperanto-3.5.7 test/test_buffer_io.rb
tracksperanto-3.5.6 test/test_buffer_io.rb
tracksperanto-3.5.5 test/test_buffer_io.rb
tracksperanto-3.5.4 test/test_buffer_io.rb
tracksperanto-3.5.2 test/test_buffer_io.rb
tracksperanto-3.5.1 test/test_buffer_io.rb
tracksperanto-3.5.0 test/test_buffer_io.rb
tracksperanto-3.4.1 test/test_buffer_io.rb
tracksperanto-3.4.0 test/test_buffer_io.rb
tracksperanto-3.3.13 test/test_buffer_io.rb