Sha256: 7d7b6958070a8ce650c4ebc276ff72d8b4d3d029be88043fd7ea4f4cd09c700e

Contents?: true

Size: 1.74 KB

Versions: 1

Compression:

Stored size: 1.74 KB

Contents

$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"

require "test/unit"
require 'writeexcel'

class TC_merge_formats < Test::Unit::TestCase

  def setup
    t = Time.now.strftime("%Y%m%d")
    path = "temp#{t}-#{$$}-#{rand(0x100000000).to_s(36)}"
    @test_file           = File.join(Dir.tmpdir, path)
    @workbook            = Spreadsheet::WriteExcel.new(@test_file)
    @worksheet           = @workbook.add_worksheet
    @merged_format       = @workbook.add_format(:bold => 1)
    @non_merged_format   = @workbook.add_format(:bold => 1)

    @worksheet.set_row(    5,    nil, @merged_format)
    @worksheet.set_column('G:G', nil, @merged_format)
  end

  def teardown
    @workbook.close
    File.unlink(@test_file) if FileTest.exist?(@test_file)
  end

  def test_some
    # Test 1   Normal usage.
    assert_nothing_raised { @worksheet.write('A1',    'Test', @non_merged_format) }
    assert_nothing_raised { @worksheet.write('A3:B4', 'Test', @merged_format) }

    # Test 2   Non merge format in merged cells.
    assert_nothing_raised {
      @worksheet.merge_range('D3:E4', 'Test', @non_merged_format)
    }

    # Test 3   Merge format in column.
    assert_nothing_raised { @worksheet.write('G1', 'Test') }

    # Test 4   Merge format in row.
    assert_nothing_raised { @worksheet.write('A6', 'Test') }

    # Test 5   Merge format in column and row.
    assert_nothing_raised { @worksheet.write('G6', 'Test') }

    # Test 6   No merge format in column and row.
    assert_nothing_raised { @worksheet.write('H7', 'Test') }

    # Test 7   Normal usage again.
    assert_nothing_raised {
      @worksheet.write('A1',    'Test', @non_merged_format)
    }
    assert_nothing_raised {
      @worksheet.merge_range('A3:B4', 'Test', @merged_format)
    }
  end


end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
writeexcel-0.1.0 test/test_02_merge_formats.rb