Sha256: fba4fd48272c7894c8cb5998953b2650f2b3d418f1cf055f4e4029a8e3ef0a6a

Contents?: true

Size: 1.91 KB

Versions: 24

Compression:

Stored size: 1.91 KB

Contents

# -*- coding: utf-8 -*-
require 'helper'
require 'stringio'

class TC_BIFFWriter < Test::Unit::TestCase

  TEST_DIR    = File.expand_path(File.dirname(__FILE__))
  PERL_OUTDIR = File.join(TEST_DIR, 'perl_output')

  def setup
    @biff = BIFFWriter.new
    @ruby_file = StringIO.new
  end

  def test_append_no_error
    assert_nothing_raised{ @biff.append("World") }
  end

  def test_prepend_no_error
    assert_nothing_raised{ @biff.prepend("Hello") }
  end

  def test_data_added
    assert_nothing_raised{ @biff.append("Hello", "World") }
    data = ''
    while d = @biff.get_data
      data += d
    end
    assert_equal("HelloWorld", data, "Bad data contents")
    assert_equal(10, @biff.datasize, "Bad data size")
  end

  def test_data_prepended

    assert_nothing_raised{ @biff.append("Hello") }
    assert_nothing_raised{ @biff.prepend("World") }
    data = ''
    while d = @biff.get_data
      data += d
    end
    assert_equal("WorldHello", data, "Bad data contents")
    assert_equal(10, @biff.datasize, "Bad data size")
  end

  def test_store_bof_length
    assert_nothing_raised{ @biff.store_bof }
    assert_equal(20, @biff.datasize, "Bad data size after store_bof call")
  end

  def test_store_eof_length
    assert_nothing_raised{ @biff.store_eof }
    assert_equal(4, @biff.datasize, "Bad data size after store_eof call")
  end

  def test_datasize_mixed
    assert_nothing_raised{ @biff.append("Hello") }
    assert_nothing_raised{ @biff.prepend("World") }
    assert_nothing_raised{ @biff.store_bof }
    assert_nothing_raised{ @biff.store_eof }
    assert_equal(34, @biff.datasize, "Bad data size for mixed data")
  end

  def test_add_continue
    perl_file = "#{PERL_OUTDIR}/biff_add_continue_testdata"
    size = File.size(perl_file)
    @ruby_file.print(@biff.add_continue('testdata'))
    rsize = @ruby_file.size
    assert_equal(size, rsize, "File sizes not the same")
    compare_file(perl_file, @ruby_file)
  end
end

Version data entries

24 entries across 24 versions & 3 rubygems

Version Path
writeexcel-1.0.5 test/test_biff.rb
writeexcel-1.0.4 test/test_biff.rb
writeexcel-1.0.3 test/test_biff.rb
writeexcel-1.0.2 test/test_biff.rb
writeexcel-1.0.1 test/test_biff.rb
writeexcel-1.0.0 test/test_biff.rb
writeexcel-0.6.19 test/test_biff.rb
writeexcel-0.6.18 test/test_biff.rb
writeexcel-0.6.17 test/test_biff.rb
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/writeexcel-0.6.16/test/test_biff.rb
writeexcel-0.6.16 test/test_biff.rb
writeexcel-0.6.15 test/test_biff.rb
writeexcel-0.6.14 test/test_biff.rb
sunrise-cms-0.3.3 vendor/bundle/ruby/1.9.1/gems/writeexcel-0.6.13/test/test_biff.rb
sunrise-cms-0.3.2 vendor/bundle/ruby/1.9.1/gems/writeexcel-0.6.13/test/test_biff.rb
sunrise-cms-0.3.1 vendor/bundle/ruby/1.9.1/gems/writeexcel-0.6.13/test/test_biff.rb
sunrise-cms-0.3.0 vendor/bundle/ruby/1.9.1/gems/writeexcel-0.6.13/test/test_biff.rb
sunrise-cms-0.3.0.rc vendor/bundle/ruby/1.9.1/gems/writeexcel-0.6.13/test/test_biff.rb
writeexcel-0.6.13 test/test_biff.rb
ricardoo27-writeexcel-0.6.12.2 test/test_biff.rb