Sha256: 78b860a4fc2cc4658e5c634f3db1e64fbf6aa773f8536cea2056046a1b54c152

Contents?: true

Size: 1.83 KB

Versions: 50

Compression:

Stored size: 1.83 KB

Contents

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

class TestWriteCell < Test::Unit::TestCase
  def setup
    @workbook = WriteXLSX.new(StringIO.new)
    @worksheet = @workbook.add_worksheet('')
  end

  def test_write_cell_0_0_n_1
    cell_data = Writexlsx::Worksheet::NumberCellData.new(@worksheet, 0, 0, 1, nil)
    cell_data.write_cell
    result = @worksheet.instance_variable_get(:@writer).string
    expected = '<c r="A1"><v>1</v></c>'
    assert_equal(expected, result)
  end

  def test_write_cell_3_1_s_0
    cell_data = Writexlsx::Worksheet::StringCellData.new(@worksheet, 3, 1, 0, nil)
    cell_data.write_cell
    result = @worksheet.instance_variable_get(:@writer).string
    expected = '<c r="B4" t="s"><v>0</v></c>'
    assert_equal(expected, result)
  end

  def test_write_cell_1_2_f_formula_nil_0
    format = nil
    cell_data = Writexlsx::Worksheet::FormulaCellData.new(@worksheet, 1, 2, 'A3+A5', format, 0)
    cell_data.write_cell
    result = @worksheet.instance_variable_get(:@writer).string
    expected = '<c r="C2"><f>A3+A5</f><v>0</v></c>'
    assert_equal(expected, result)
  end

  def test_write_cell_1_2_f_formula
    format = nil
    cell_data = Writexlsx::Worksheet::FormulaCellData.new(@worksheet, 1, 2, 'A3+A5', nil, nil)
    cell_data.write_cell
    result = @worksheet.instance_variable_get(:@writer).string
    expected = '<c r="C2"><f>A3+A5</f><v>0</v></c>'
    assert_equal(expected, result)
  end

  def test_write_cell_0_0_a_formula_nil_a1_9500
    format = nil
    cell_data = Writexlsx::Worksheet::FormulaArrayCellData.new(@worksheet, 0, 0, 'SUM(B1:C1*B2:C2)', format, 'A1', 9500)
    cell_data.write_cell
    result = @worksheet.instance_variable_get(:@writer).string
    expected = '<c r="A1"><f t="array" ref="A1">SUM(B1:C1*B2:C2)</f><v>9500</v></c>'
    assert_equal(expected, result)
  end
end

Version data entries

50 entries across 50 versions & 1 rubygems

Version Path
write_xlsx-0.86.0 test/worksheet/test_write_cell.rb
write_xlsx-0.85.11 test/worksheet/test_write_cell.rb
write_xlsx-0.85.10 test/worksheet/test_write_cell.rb
write_xlsx-0.85.9 test/worksheet/test_write_cell.rb
write_xlsx-0.85.8 test/worksheet/test_write_cell.rb
write_xlsx-0.85.7 test/worksheet/test_write_cell.rb
write_xlsx-0.85.6 test/worksheet/test_write_cell.rb
write_xlsx-0.85.5 test/worksheet/test_write_cell.rb
write_xlsx-0.85.4 test/worksheet/test_write_cell.rb
write_xlsx-0.85.3 test/worksheet/test_write_cell.rb
write_xlsx-0.85.2 test/worksheet/test_write_cell.rb
write_xlsx-0.85.1 test/worksheet/test_write_cell.rb
write_xlsx-0.83.0 test/worksheet/test_write_cell.rb
write_xlsx-0.81.1 test/worksheet/test_write_cell.rb
write_xlsx-0.81.0 test/worksheet/test_write_cell.rb
write_xlsx-0.80.0 test/worksheet/test_write_cell.rb
write_xlsx-0.79.0 test/worksheet/test_write_cell.rb
write_xlsx-0.78.0 test/worksheet/test_write_cell.rb
write_xlsx-0.77.2 test/worksheet/test_write_cell.rb
write_xlsx-0.77.1 test/worksheet/test_write_cell.rb