summaryrefslogtreecommitdiffhomepage
path: root/test/workbook
diff options
context:
space:
mode:
authorRandy Morgan <[email protected]>2012-04-01 17:00:06 -0700
committerRandy Morgan <[email protected]>2012-04-01 17:00:06 -0700
commitbcc7c8c4e85a6ed53f134d633e8f81fd313d6c8d (patch)
tree9a474295ec099e303b3711338962d84cb7a43596 /test/workbook
parent225edfc837e99167072fdf15e4ee3a5af9cfe96c (diff)
parent44c77ed27b20c4ebe1c9c8faf6ad80701d7f567e (diff)
downloadcaxlsx-bcc7c8c4e85a6ed53f134d633e8f81fd313d6c8d.tar.gz
caxlsx-bcc7c8c4e85a6ed53f134d633e8f81fd313d6c8d.zip
Merge pull request #74 from joekain/wide
Wide
Diffstat (limited to 'test/workbook')
-rw-r--r--test/workbook/worksheet/tc_cell.rb40
1 files changed, 40 insertions, 0 deletions
diff --git a/test/workbook/worksheet/tc_cell.rb b/test/workbook/worksheet/tc_cell.rb
index 4db0c7be..c35e62bc 100644
--- a/test/workbook/worksheet/tc_cell.rb
+++ b/test/workbook/worksheet/tc_cell.rb
@@ -13,6 +13,30 @@ 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")
@@ -41,6 +65,22 @@ 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
+ end
+
def test_r_abs
assert_equal(@c.r_abs,"$A$1", "calculate absolute cell reference")
assert_equal(@cAA.r_abs,"$AA$2", "needs to accept multi-digit columns")