summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorJoe Kain <[email protected]>2012-03-31 19:00:18 -0700
committerJoe Kain <[email protected]>2012-04-01 00:05:30 -0700
commitbff4c5ecfa730c6f5af35577a5cb83562512866e (patch)
tree967abe6e9369d8bacab259317654a01edac81478 /test
parent225edfc837e99167072fdf15e4ee3a5af9cfe96c (diff)
downloadcaxlsx-bff4c5ecfa730c6f5af35577a5cb83562512866e.tar.gz
caxlsx-bff4c5ecfa730c6f5af35577a5cb83562512866e.zip
Test 3+ letter column references and indices.
Diffstat (limited to 'test')
-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")