diff options
| author | Randy Morgan <[email protected]> | 2013-08-19 23:15:05 +0900 |
|---|---|---|
| committer | Randy Morgan <[email protected]> | 2013-08-19 23:15:05 +0900 |
| commit | dd1f24a10f6842e8c4e6254eef586c383791cd03 (patch) | |
| tree | ff2f90f0638263dacb91ad2e8fc992b10f3e8bc8 /test | |
| parent | bcaeecc9aee01c6e9f8b801074f18d35c2cc803c (diff) | |
| download | caxlsx-dd1f24a10f6842e8c4e6254eef586c383791cd03.tar.gz caxlsx-dd1f24a10f6842e8c4e6254eef586c383791cd03.zip | |
More work on page breaks
Diffstat (limited to 'test')
| -rw-r--r-- | test/profile.rb | 10 | ||||
| -rw-r--r-- | test/workbook/worksheet/tc_break.rb | 20 | ||||
| -rw-r--r-- | test/workbook/worksheet/tc_worksheet.rb | 13 |
3 files changed, 39 insertions, 4 deletions
diff --git a/test/profile.rb b/test/profile.rb index ffe057e4..de00b32b 100644 --- a/test/profile.rb +++ b/test/profile.rb @@ -3,6 +3,8 @@ $:.unshift "#{File.dirname(__FILE__)}/../lib" require 'axlsx' require 'ruby-prof' +#RubyProf.measure_mode = RubyProf::MEMORY +# row = [] # Taking worst case scenario of all string data input = (32..126).to_a.pack('U*').chars.to_a @@ -11,10 +13,12 @@ input = (32..126).to_a.pack('U*').chars.to_a profile = RubyProf.profile do p = Axlsx::Package.new p.workbook.add_worksheet do |sheet| - 30.times do + 10000.times do sheet << row end end + p.to_stream end -printer = RubyProf::CallTreePrinter.new(profile) -printer.print(File.new('axlsx.qcachegrind', 'w')) + +printer = RubyProf::FlatPrinter.new(profile) +printer.print(STDOUT, {}) diff --git a/test/workbook/worksheet/tc_break.rb b/test/workbook/worksheet/tc_break.rb index 9f235dfe..c0ad69ca 100644 --- a/test/workbook/worksheet/tc_break.rb +++ b/test/workbook/worksheet/tc_break.rb @@ -5,7 +5,7 @@ class TestBreak < Test::Unit::TestCase def setup p = Axlsx::Package.new ws = p.workbook.add_worksheet - @break = Axlsx::Break.new(ws, {id: 1, min: 1, max: 10, man: true, pt: false}) + @break = Axlsx::Break.new(id: 1, min: 1, max: 10, man: true, pt: false) end def test_id @@ -16,17 +16,35 @@ class TestBreak < Test::Unit::TestCase end def test_min + assert_equal(1, @break.min) + assert_raises ArgumentError do + Axlsx::Break.new(:hoge, min: -1) + end end def test_max + assert_equal(10, @break.max) + assert_raises ArgumentError do + Axlsx::Break.new(:hoge, max: -1) + end end + def test_man + assert_equal(true, @break.man) + assert_raises ArgumentError do + Axlsx::Break.new(man: -1) + end end def test_pt + assert_equal(false, @break.pt) + assert_raises ArgumentError do + Axlsx::Break.new(pt: -1) + end end def test_to_xml_string + assert_equal("<brk id=\"1\" min=\"1\" max=\"10\" man=\"true\" pt=\"false\" ></brk>", @break.to_xml_string) end end diff --git a/test/workbook/worksheet/tc_worksheet.rb b/test/workbook/worksheet/tc_worksheet.rb index 00983fec..505d314c 100644 --- a/test/workbook/worksheet/tc_worksheet.rb +++ b/test/workbook/worksheet/tc_worksheet.rb @@ -167,6 +167,13 @@ class TestWorksheet < Test::Unit::TestCase assert_equal(@ws.workbook.charts.size, 1, "add_chart adds a chart to the workbook") end + def test_add_page_break + assert(@ws.row_breaks.empty?) + assert(@ws.col_breaks.empty?) + @ws.add_page_break(10) + assert_equal(@ws.row_breaks.size, 1) + end + def test_drawing assert @ws.drawing == nil @ws.add_chart(Axlsx::Pie3DChart) @@ -293,6 +300,12 @@ class TestWorksheet < Test::Unit::TestCase assert_equal(doc.xpath('//xmlns:worksheet/xmlns:mergeCells/xmlns:mergeCell[@ref="E1:F1"]').size, 1) end + def test_to_xml_string_row_breaks + @ws.add_page_break(1) + doc = Nokogiri::XML(@ws.to_xml_string) + assert_equal(doc.xpath('//xmlns:worksheet/xmlns:rowBreaks/xmlns:brk[@id="1"]').size, 1) + end + def test_to_xml_string_sheet_protection @ws.sheet_protection.password = 'fish' doc = Nokogiri::XML(@ws.to_xml_string) |
