summaryrefslogtreecommitdiffhomepage
path: root/test/workbook/tc_shared_strings_table.rb
diff options
context:
space:
mode:
authorRandy Morgan <[email protected]>2012-02-12 12:55:25 +0900
committerRandy Morgan <[email protected]>2012-02-12 12:55:25 +0900
commit376988c854889d7b9708601bce11575a11491bee (patch)
tree963e196ae76022e84dbbe1a2cf293c840182be08 /test/workbook/tc_shared_strings_table.rb
parent6272d7bc63ee05b6793d034461af3ee811ffe72a (diff)
downloadcaxlsx-376988c854889d7b9708601bce11575a11491bee.tar.gz
caxlsx-376988c854889d7b9708601bce11575a11491bee.zip
Adding in support for optionally using the shared strings table. This will allow us to inter-op properly with Numbers
Diffstat (limited to 'test/workbook/tc_shared_strings_table.rb')
-rw-r--r--test/workbook/tc_shared_strings_table.rb39
1 files changed, 39 insertions, 0 deletions
diff --git a/test/workbook/tc_shared_strings_table.rb b/test/workbook/tc_shared_strings_table.rb
new file mode 100644
index 00000000..b0e9de05
--- /dev/null
+++ b/test/workbook/tc_shared_strings_table.rb
@@ -0,0 +1,39 @@
+require 'test/unit'
+require 'axlsx.rb'
+
+class TestSharedStringsTable < Test::Unit::TestCase
+
+ def setup
+ @p = Axlsx::Package.new :use_shared_strings=>true
+ ws = @p.workbook.add_worksheet
+ ws.add_row ['a', 1, 'b']
+ ws.add_row ['b', 1, 'c']
+ ws.add_row ['c', 1, 'd']
+ end
+
+ def test_workbook_has_shared_strings
+ assert(@p.workbook.shared_strings.is_a?(Axlsx::SharedStringsTable), "shared string table was not created")
+ end
+
+ def test_count
+ sst = @p.workbook.shared_strings
+ assert_equal(sst.count, 6)
+ end
+
+ def test_unique_count
+ sst = @p.workbook.shared_strings
+ assert_equal(sst.unique_count, 4)
+ end
+
+ def test_valid_document
+ schema = Nokogiri::XML::Schema(File.open(Axlsx::SML_XSD))
+ doc = Nokogiri::XML(@p.workbook.shared_strings.to_xml)
+ errors = []
+ schema.validate(doc).each do |error|
+ puts error.message
+ errors << error
+ end
+ assert_equal(errors.size, 0, "sharedStirngs.xml Invalid" + errors.map{ |e| e.message }.to_s)
+ end
+
+end