diff options
| author | Randy Morgan <[email protected]> | 2012-04-02 20:09:33 +0900 |
|---|---|---|
| committer | Randy Morgan <[email protected]> | 2012-04-02 20:09:33 +0900 |
| commit | 6f998ecb098c2a3a5eabc6f8ef44a0f25632f2c8 (patch) | |
| tree | 9091b0053dc139ec904d208a0ef9f6050efd78ef | |
| parent | bcc7c8c4e85a6ed53f134d633e8f81fd313d6c8d (diff) | |
| download | caxlsx-6f998ecb098c2a3a5eabc6f8ef44a0f25632f2c8.tar.gz caxlsx-6f998ecb098c2a3a5eabc6f8ef44a0f25632f2c8.zip | |
move axlsx.rb helper methods into separate test suite.
| -rw-r--r-- | test/tc_axlsx.rb | 39 | ||||
| -rw-r--r-- | test/workbook/worksheet/tc_cell.rb | 38 |
2 files changed, 40 insertions, 37 deletions
diff --git a/test/tc_axlsx.rb b/test/tc_axlsx.rb new file mode 100644 index 00000000..fe3b7edd --- /dev/null +++ b/test/tc_axlsx.rb @@ -0,0 +1,39 @@ +require 'tc_helper.rb' + +class TestAxlsx < Test::Unit::TestCase + + def setup_wide + @wide_test_points = { "A3" => 0, + "Z3" => 25, + "B3" => 1, + "AA3" => 1 * 26 + 0, + "AAA3" => 1 * 26**2 + 1 * 26 + 0, + "AAZ3" => 1 * 26**2 + 1 * 26 + 25, + "ABA3" => 1 * 26**2 + 2 * 26 + 0, + "BZU3" => 2 * 26**2 + 26 * 26 + 20 + } + end + + def test_cell_range + #To do + end + + def test_name_to_indices + setup_wide + @wide_test_points.each do |key, value| + assert_equal(Axlsx.name_to_indices(key), [value,2]) + end + end + + def test_col_ref + setup_wide + @wide_test_points.each do |key, value| + assert_equal(Axlsx.col_ref(value), key.gsub(/\d+/, '')) + end + end + + def test_cell_r + # todo + end + +end diff --git a/test/workbook/worksheet/tc_cell.rb b/test/workbook/worksheet/tc_cell.rb index c35e62bc..2313a8ba 100644 --- a/test/workbook/worksheet/tc_cell.rb +++ b/test/workbook/worksheet/tc_cell.rb @@ -13,30 +13,6 @@ class TestCell < Test::Unit::TestCase @cAA = @ws["AA2"] end - def setup_wide - # The wide row makes the test take a long time. Add it only - # in test_large as adding it in setup make all the tests take - # longer. - # - # For even more, but slower, testing use the 20000 cell row and - # uncomment the ABCD3 element below. - data = (0..1000).map { |index| index } - #data = (0..20000).map { |index| index } - @ws.add_row data - - @wide_test_points = { "A3" => 0, - "Z3" => 25, - "B3" => 1, - "AA3" => 1 * 26 + 0, - "AAA3" => 1 * 26**2 + 1 * 26 + 0, - "AAZ3" => 1 * 26**2 + 1 * 26 + 25, - "ABA3" => 1 * 26**2 + 2 * 26 + 0, - - # For additional testing, uncomment this line and uncomment the 20000 cell row above - #"ABCD3" => 1 * 26**3 + 2 * 26**2 + 3 * 26 + 3 - } - end - def test_initialize assert_equal(@row.cells.last, @c, "the cell was added to the row") assert_equal(@c.type, :float, "type option is applied") @@ -65,20 +41,8 @@ class TestCell < Test::Unit::TestCase assert_equal(@c.r, "A1", "calculate cell reference") end - def test_wide_index - setup_wide - @wide_test_points.each_pair do |ref, index| - c = @ws[ref] - assert_equal(c.index, index, "calculate cell index for cell #{ref}") - end - end - def test_wide_r - setup_wide - @wide_test_points.each_pair do |ref, index| - c = @ws[ref] - assert_equal(c.r, ref, "calculate cell reference for cell at index #{index}") - end + assert_equal(@cAA.r, "AA2", "calculate cell reference") end def test_r_abs |
