Sha256: d4c859d1b279e7ba019d437e603564f0b69f169e52d7f98093b203de24e387a4

Contents?: true

Size: 1.62 KB

Versions: 19

Compression:

Stored size: 1.62 KB

Contents

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

class TestGetChartRange < Minitest::Test
  def setup
    @workbook = WriteXLSX.new(StringIO.new)
  end

  def test_get_chart_range_simple_formula
    formula = 'Sheet1!$B$1:$B$5'
    result = @workbook.__send__('get_chart_range', formula)
    expected = ['Sheet1', 0, 1, 4, 1]
    assert_equal(expected, result)
  end

  def test_get_chart_range_sheetname_with_space
    formula  = "'Sheet 1'!$B$1:$B$5"
    result = @workbook.__send__('get_chart_range', formula)
    expected = ['Sheet 1', 0, 1, 4, 1]
    assert_equal(expected, result)
  end

  def test_get_chart_range_single_cell_range
    formula  = 'Sheet1!$B$1'
    result = @workbook.__send__('get_chart_range', formula)
    expected = ['Sheet1', 0, 1, 0, 1]
    assert_equal(expected, result)
  end

  def test_get_chart_range_sheet_name_with_an_apostrophe
    formula  = "'Don''t'!$B$1:$B$5"
    result = @workbook.__send__('get_chart_range', formula)
    expected = ["Don't", 0, 1, 4, 1]
    assert_equal(expected, result)
  end

  def test_get_chart_range_sheet_name_with_exclamation_mark
    formula  = "'aa!bb'!$B$1:$B$5"
    result = @workbook.__send__('get_chart_range', formula)
    expected = ['aa!bb', 0, 1, 4, 1]
    assert_equal(expected, result)
  end

  def test_get_chart_range_sheet_name_with_invalid_range
    formula  = ''
    result = @workbook.__send__('get_chart_range', formula)
    assert_nil(result)
  end

  def test_get_chart_range_sheet_name_with_invalid_2d_range
    formula  = 'Sheet1!$B$1:$F$5'
    result = @workbook.__send__('get_chart_range', formula)
    assert_nil(result)
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
write_xlsx-1.09.4 test/workbook/test_get_chart_range.rb
write_xlsx-1.09.3 test/workbook/test_get_chart_range.rb
write_xlsx-1.09.2 test/workbook/test_get_chart_range.rb
write_xlsx-1.09.1 test/workbook/test_get_chart_range.rb
write_xlsx-1.09.0 test/workbook/test_get_chart_range.rb
write_xlsx-1.08.2 test/workbook/test_get_chart_range.rb
write_xlsx-1.08.1 test/workbook/test_get_chart_range.rb
write_xlsx-1.08.0 test/workbook/test_get_chart_range.rb
write_xlsx-1.07.0 test/workbook/test_get_chart_range.rb
write_xlsx-1.04.0 test/workbook/test_get_chart_range.rb
write_xlsx-1.02.0 test/workbook/test_get_chart_range.rb
write_xlsx-1.01.0 test/workbook/test_get_chart_range.rb
write_xlsx-1.00.0 test/workbook/test_get_chart_range.rb
write_xlsx-0.99.0 test/workbook/test_get_chart_range.rb
write_xlsx-0.97.0 test/workbook/test_get_chart_range.rb
write_xlsx-0.90.0 test/workbook/test_get_chart_range.rb
write_xlsx-0.89.0 test/workbook/test_get_chart_range.rb
write_xlsx-0.88.0 test/workbook/test_get_chart_range.rb
write_xlsx-0.87.0 test/workbook/test_get_chart_range.rb