axlsx 1.0.12 → 1.0.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. data/README.md +7 -3
  2. data/lib/axlsx.rb +57 -0
  3. data/lib/axlsx/content_type/content_type.rb +23 -0
  4. data/lib/axlsx/content_type/default.rb +37 -0
  5. data/lib/axlsx/content_type/override.rb +37 -0
  6. data/lib/axlsx/doc_props/app.rb +178 -0
  7. data/lib/axlsx/doc_props/core.rb +34 -0
  8. data/lib/axlsx/drawing/axis.rb +90 -0
  9. data/lib/axlsx/drawing/bar_3D_chart.rb +128 -0
  10. data/lib/axlsx/drawing/bar_series.rb +64 -0
  11. data/lib/axlsx/drawing/cat_axis.rb +63 -0
  12. data/lib/axlsx/drawing/cat_axis_data.rb +35 -0
  13. data/lib/axlsx/drawing/chart.rb +179 -0
  14. data/lib/axlsx/drawing/drawing.rb +137 -0
  15. data/lib/axlsx/drawing/graphic_frame.rb +52 -0
  16. data/lib/axlsx/drawing/line_3D_chart.rb +106 -0
  17. data/lib/axlsx/drawing/line_series.rb +46 -0
  18. data/lib/axlsx/drawing/marker.rb +61 -0
  19. data/lib/axlsx/drawing/one_cell_anchor.rb +89 -0
  20. data/lib/axlsx/drawing/pic.rb +153 -0
  21. data/lib/axlsx/drawing/picture_locking.rb +72 -0
  22. data/lib/axlsx/drawing/picture_locking.rb~ +36 -0
  23. data/lib/axlsx/drawing/pie_3D_chart.rb +41 -0
  24. data/lib/axlsx/drawing/pie_series.rb +56 -0
  25. data/lib/axlsx/drawing/scaling.rb +59 -0
  26. data/lib/axlsx/drawing/ser_axis.rb +45 -0
  27. data/lib/axlsx/drawing/series.rb +71 -0
  28. data/lib/axlsx/drawing/series_title.rb +22 -0
  29. data/lib/axlsx/drawing/title.rb +61 -0
  30. data/lib/axlsx/drawing/two_cell_anchor.rb +76 -0
  31. data/lib/axlsx/drawing/val_axis.rb +34 -0
  32. data/lib/axlsx/drawing/val_axis_data.rb +28 -0
  33. data/lib/axlsx/drawing/view_3D.rb +85 -0
  34. data/lib/axlsx/package.rb +215 -0
  35. data/lib/axlsx/rels/relationship.rb +44 -0
  36. data/lib/axlsx/rels/relationships.rb +25 -0
  37. data/lib/axlsx/stylesheet/border.rb +57 -0
  38. data/lib/axlsx/stylesheet/border_pr.rb +68 -0
  39. data/lib/axlsx/stylesheet/cell_alignment.rb +105 -0
  40. data/lib/axlsx/stylesheet/cell_protection.rb +36 -0
  41. data/lib/axlsx/stylesheet/cell_style.rb +65 -0
  42. data/lib/axlsx/stylesheet/color.rb +69 -0
  43. data/lib/axlsx/stylesheet/fill.rb +32 -0
  44. data/lib/axlsx/stylesheet/font.rb +139 -0
  45. data/lib/axlsx/stylesheet/gradient_fill.rb +76 -0
  46. data/lib/axlsx/stylesheet/gradient_stop.rb +33 -0
  47. data/lib/axlsx/stylesheet/num_fmt.rb +63 -0
  48. data/lib/axlsx/stylesheet/pattern_fill.rb +66 -0
  49. data/lib/axlsx/stylesheet/styles.rb +298 -0
  50. data/lib/axlsx/stylesheet/table_style.rb +47 -0
  51. data/lib/axlsx/stylesheet/table_style_element.rb +71 -0
  52. data/lib/axlsx/stylesheet/table_styles.rb +39 -0
  53. data/lib/axlsx/stylesheet/xf.rb +138 -0
  54. data/lib/axlsx/util/constants.rb +220 -0
  55. data/lib/axlsx/util/parser.rb +43 -0
  56. data/lib/axlsx/util/parser.rb~ +6 -0
  57. data/lib/axlsx/util/simple_typed_list.rb +160 -0
  58. data/lib/axlsx/util/validators.rb +132 -0
  59. data/lib/axlsx/version.rb +4 -0
  60. data/lib/axlsx/workbook/#workbook.rb# +165 -0
  61. data/lib/axlsx/workbook/workbook.rb +160 -0
  62. data/lib/axlsx/workbook/worksheet/cell.rb +337 -0
  63. data/lib/axlsx/workbook/worksheet/row.rb +107 -0
  64. data/lib/axlsx/workbook/worksheet/worksheet.rb +279 -0
  65. metadata +93 -141
  66. data/examples/follow_20111202.xlsx +0 -0
  67. data/test/content_type/tc_content_type.rb +0 -81
  68. data/test/content_type/tc_default.rb +0 -40
  69. data/test/content_type/tc_override.rb +0 -40
  70. data/test/doc_props/tc_app.rb +0 -19
  71. data/test/doc_props/tc_core.rb +0 -34
  72. data/test/drawing/tc_axis.rb +0 -40
  73. data/test/drawing/tc_bar_3D_chart.rb +0 -66
  74. data/test/drawing/tc_bar_series.rb +0 -34
  75. data/test/drawing/tc_cat_axis.rb +0 -32
  76. data/test/drawing/tc_cat_axis_data.rb +0 -18
  77. data/test/drawing/tc_chart.rb +0 -73
  78. data/test/drawing/tc_drawing.rb +0 -80
  79. data/test/drawing/tc_graphic_frame.rb +0 -26
  80. data/test/drawing/tc_line_3d_chart.rb +0 -48
  81. data/test/drawing/tc_line_series.rb +0 -27
  82. data/test/drawing/tc_marker.rb +0 -45
  83. data/test/drawing/tc_one_cell_anchor.rb +0 -67
  84. data/test/drawing/tc_pic.rb +0 -71
  85. data/test/drawing/tc_picture_locking.rb +0 -73
  86. data/test/drawing/tc_pie_3D_chart.rb +0 -33
  87. data/test/drawing/tc_pie_series.rb +0 -35
  88. data/test/drawing/tc_scaling.rb +0 -37
  89. data/test/drawing/tc_ser_axis.rb +0 -31
  90. data/test/drawing/tc_series.rb +0 -24
  91. data/test/drawing/tc_series_title.rb +0 -34
  92. data/test/drawing/tc_title.rb +0 -34
  93. data/test/drawing/tc_two_cell_anchor.rb +0 -38
  94. data/test/drawing/tc_val_axis.rb +0 -25
  95. data/test/drawing/tc_val_axis_data.rb +0 -18
  96. data/test/drawing/tc_view_3D.rb +0 -55
  97. data/test/rels/tc_relationship.rb +0 -16
  98. data/test/rels/tc_relationships.rb +0 -27
  99. data/test/stylesheet/tc_border.rb +0 -38
  100. data/test/stylesheet/tc_border_pr.rb +0 -33
  101. data/test/stylesheet/tc_cell_alignment.rb +0 -77
  102. data/test/stylesheet/tc_cell_protection.rb +0 -30
  103. data/test/stylesheet/tc_cell_style.rb +0 -58
  104. data/test/stylesheet/tc_color.rb +0 -38
  105. data/test/stylesheet/tc_fill.rb +0 -19
  106. data/test/stylesheet/tc_font.rb +0 -114
  107. data/test/stylesheet/tc_gradient_fill.rb +0 -65
  108. data/test/stylesheet/tc_gradient_stop.rb +0 -32
  109. data/test/stylesheet/tc_num_fmt.rb +0 -31
  110. data/test/stylesheet/tc_pattern_fill.rb +0 -38
  111. data/test/stylesheet/tc_styles.rb +0 -52
  112. data/test/stylesheet/tc_table_style.rb +0 -37
  113. data/test/stylesheet/tc_table_style_element.rb +0 -37
  114. data/test/stylesheet/tc_table_styles.rb +0 -30
  115. data/test/stylesheet/tc_xf.rb +0 -121
  116. data/test/tc_package.rb +0 -68
  117. data/test/util/tc_simple_typed_list.rb +0 -66
  118. data/test/util/tc_validators.rb +0 -76
  119. data/test/workbook/tc_workbook.rb +0 -60
  120. data/test/workbook/worksheet/tc_cell.rb +0 -179
  121. data/test/workbook/worksheet/tc_row.rb +0 -36
  122. data/test/workbook/worksheet/tc_worksheet.rb +0 -138
@@ -1,38 +0,0 @@
1
- require 'test/unit'
2
- require 'axlsx.rb'
3
-
4
- class TestPatternFill < Test::Unit::TestCase
5
-
6
- def setup
7
- @item = Axlsx::PatternFill.new
8
- end
9
-
10
- def teardown
11
- end
12
-
13
-
14
- def test_initialiation
15
- assert_equal(@item.patternType, :none)
16
- assert_equal(@item.bgColor, nil)
17
- assert_equal(@item.fgColor, nil)
18
- end
19
-
20
- def test_bgColor
21
- assert_raise(ArgumentError) { @item.bgColor = -1.1 }
22
- assert_nothing_raised { @item.bgColor = Axlsx::Color.new }
23
- assert_equal(@item.bgColor.rgb, "FF000000")
24
- end
25
-
26
- def test_fgColor
27
- assert_raise(ArgumentError) { @item.fgColor = -1.1 }
28
- assert_nothing_raised { @item.fgColor = Axlsx::Color.new }
29
- assert_equal(@item.fgColor.rgb, "FF000000")
30
- end
31
-
32
- def test_pattern_type
33
- assert_raise(ArgumentError) { @item.patternType = -1.1 }
34
- assert_nothing_raised { @item.patternType = :lightUp }
35
- assert_equal(@item.patternType, :lightUp)
36
- end
37
-
38
- end
@@ -1,52 +0,0 @@
1
- require 'test/unit'
2
- require 'axlsx.rb'
3
-
4
- class TestStyles < Test::Unit::TestCase
5
- def setup
6
- @styles = Axlsx::Styles.new
7
- end
8
- def teardown
9
- end
10
-
11
- def test_valid_document
12
- schema = Nokogiri::XML::Schema(File.open(Axlsx::SML_XSD))
13
- doc = Nokogiri::XML(@styles.to_xml)
14
- errors = []
15
- schema.validate(doc).each do |error|
16
- errors.push error
17
- puts error.message
18
- end
19
- assert(errors.size == 0)
20
- end
21
-
22
-
23
- def test_add_style
24
- fill_count = @styles.fills.size
25
- font_count = @styles.fonts.size
26
- xf_count = @styles.cellXfs.size
27
-
28
- @styles.add_style :bg_color=>"FF000000", :fg_color=>"FFFFFFFF", :sz=>13, :num_fmt=>Axlsx::NUM_FMT_PERCENT, :alignment=>{:horizontal=>:left}, :border=>Axlsx::STYLE_THIN_BORDER, :hidden=>true, :locked=>true
29
- assert_equal(@styles.fills.size, fill_count+1)
30
- assert_equal(@styles.fonts.size, font_count+1)
31
- assert_equal(@styles.cellXfs.size, xf_count+1)
32
- xf = @styles.cellXfs.last
33
- assert_equal(xf.fillId, (@styles.fills.size-1), "points to the last created fill")
34
- assert_equal(@styles.fills.last.fill_type.fgColor.rgb, "FF000000", "fill created with color")
35
-
36
- assert_equal(xf.fontId, (@styles.fonts.size-1), "points to the last created font")
37
- assert_equal(@styles.fonts.last.sz, 13, "font sz applied")
38
- assert_equal(@styles.fonts.last.color.rgb, "FFFFFFFF", "font color applied")
39
-
40
- assert_equal(xf.borderId, Axlsx::STYLE_THIN_BORDER, "border id is set")
41
- assert_equal(xf.numFmtId, Axlsx::NUM_FMT_PERCENT, "number format id is set")
42
-
43
- assert(xf.alignment.is_a?(Axlsx::CellAlignment), "alignment was created")
44
- assert_equal(xf.alignment.horizontal, :left, "horizontal alignment applied")
45
- assert_equal(xf.applyProtection, 1, "protection applied")
46
- assert_equal(xf.protection.hidden, true, "hidden protection set")
47
- assert_equal(xf.protection.locked, true, "cell locking set")
48
- assert_raise(ArgumentError, "should reject invalid borderId") { @styles.add_style :border => 2 }
49
-
50
- end
51
-
52
- end
@@ -1,37 +0,0 @@
1
- require 'test/unit'
2
- require 'axlsx.rb'
3
-
4
- class TestTableStyle < Test::Unit::TestCase
5
-
6
- def setup
7
- @item = Axlsx::TableStyle.new "fisher"
8
- end
9
-
10
- def teardown
11
- end
12
-
13
- def test_initialiation
14
- assert_equal(@item.name, "fisher")
15
- assert_equal(@item.pivot, nil)
16
- assert_equal(@item.table, nil)
17
- end
18
-
19
- def test_name
20
- assert_raise(ArgumentError) { @item.name = -1.1 }
21
- assert_nothing_raised { @item.name = "lovely table style" }
22
- assert_equal(@item.name, "lovely table style")
23
- end
24
-
25
- def test_pivot
26
- assert_raise(ArgumentError) { @item.pivot = -1.1 }
27
- assert_nothing_raised { @item.pivot = true }
28
- assert_equal(@item.pivot, true)
29
- end
30
-
31
- def test_table
32
- assert_raise(ArgumentError) { @item.table = -1.1 }
33
- assert_nothing_raised { @item.table = true }
34
- assert_equal(@item.table, true)
35
- end
36
-
37
- end
@@ -1,37 +0,0 @@
1
- require 'test/unit'
2
- require 'axlsx.rb'
3
-
4
- class TestTableStyleElement < Test::Unit::TestCase
5
-
6
- def setup
7
- @item = Axlsx::TableStyleElement.new
8
- end
9
-
10
- def teardown
11
- end
12
-
13
- def test_initialiation
14
- assert_equal(@item.type, nil)
15
- assert_equal(@item.size, nil)
16
- assert_equal(@item.dxfId, nil)
17
- end
18
-
19
- def test_type
20
- assert_raise(ArgumentError) { @item.type = -1.1 }
21
- assert_nothing_raised { @item.type = :blankRow }
22
- assert_equal(@item.type, :blankRow)
23
- end
24
-
25
- def test_size
26
- assert_raise(ArgumentError) { @item.size = -1.1 }
27
- assert_nothing_raised { @item.size = 2 }
28
- assert_equal(@item.size, 2)
29
- end
30
-
31
- def test_dxfId
32
- assert_raise(ArgumentError) { @item.dxfId = -1.1 }
33
- assert_nothing_raised { @item.dxfId = 7 }
34
- assert_equal(@item.dxfId, 7)
35
- end
36
-
37
- end
@@ -1,30 +0,0 @@
1
- require 'test/unit'
2
- require 'axlsx.rb'
3
-
4
- class TestTableStyles < Test::Unit::TestCase
5
-
6
- def setup
7
- @item = Axlsx::TableStyles.new
8
- end
9
-
10
- def teardown
11
- end
12
-
13
- def test_initialiation
14
- assert_equal(@item.defaultTableStyle, "TableStyleMedium9")
15
- assert_equal(@item.defaultPivotStyle, "PivotStyleLight16")
16
- end
17
-
18
- def test_defaultTableStyle
19
- assert_raise(ArgumentError) { @item.defaultTableStyle = -1.1 }
20
- assert_nothing_raised { @item.defaultTableStyle = "anyones guess" }
21
- assert_equal(@item.defaultTableStyle, "anyones guess")
22
- end
23
-
24
- def test_defaultPivotStyle
25
- assert_raise(ArgumentError) { @item.defaultPivotStyle = -1.1 }
26
- assert_nothing_raised { @item.defaultPivotStyle = "anyones guess" }
27
- assert_equal(@item.defaultPivotStyle, "anyones guess")
28
- end
29
-
30
- end
@@ -1,121 +0,0 @@
1
- require 'test/unit'
2
- require 'axlsx.rb'
3
-
4
- class TestXf < Test::Unit::TestCase
5
-
6
- def setup
7
- @item = Axlsx::Xf.new
8
- end
9
-
10
- def teardown
11
- end
12
-
13
- def test_initialiation
14
- assert_equal(@item.alignment, nil)
15
- assert_equal(@item.protection, nil)
16
- assert_equal(@item.numFmtId, nil)
17
- assert_equal(@item.fontId, nil)
18
- assert_equal(@item.fillId, nil)
19
- assert_equal(@item.borderId, nil)
20
- assert_equal(@item.xfId, nil)
21
- assert_equal(@item.quotePrefix, nil)
22
- assert_equal(@item.pivotButton, nil)
23
- assert_equal(@item.applyNumberFormat, nil)
24
- assert_equal(@item.applyFont, nil)
25
- assert_equal(@item.applyFill, nil)
26
- assert_equal(@item.applyBorder, nil)
27
- assert_equal(@item.applyAlignment, nil)
28
- assert_equal(@item.applyProtection, nil)
29
- end
30
-
31
- def test_alignment
32
- assert_raise(ArgumentError) { @item.alignment = -1.1 }
33
- assert_nothing_raised { @item.alignment = Axlsx::CellAlignment.new }
34
- assert(@item.alignment.is_a?(Axlsx::CellAlignment))
35
- end
36
-
37
- def test_protection
38
- assert_raise(ArgumentError) { @item.protection = -1.1 }
39
- assert_nothing_raised { @item.protection = Axlsx::CellProtection.new }
40
- assert(@item.protection.is_a?(Axlsx::CellProtection))
41
- end
42
-
43
- def test_numFmtId
44
- assert_raise(ArgumentError) { @item.numFmtId = -1.1 }
45
- assert_nothing_raised { @item.numFmtId = 0 }
46
- assert_equal(@item.numFmtId, 0)
47
- end
48
-
49
- def test_fillId
50
- assert_raise(ArgumentError) { @item.fillId = -1.1 }
51
- assert_nothing_raised { @item.fillId = 0 }
52
- assert_equal(@item.fillId, 0)
53
- end
54
-
55
- def test_fontId
56
- assert_raise(ArgumentError) { @item.fontId = -1.1 }
57
- assert_nothing_raised { @item.fontId = 0 }
58
- assert_equal(@item.fontId, 0)
59
- end
60
-
61
- def test_borderId
62
- assert_raise(ArgumentError) { @item.borderId = -1.1 }
63
- assert_nothing_raised { @item.borderId = 0 }
64
- assert_equal(@item.borderId, 0)
65
- end
66
-
67
- def test_xfId
68
- assert_raise(ArgumentError) { @item.xfId = -1.1 }
69
- assert_nothing_raised { @item.xfId = 0 }
70
- assert_equal(@item.xfId, 0)
71
- end
72
-
73
- def test_quotePrefix
74
- assert_raise(ArgumentError) { @item.quotePrefix = -1.1 }
75
- assert_nothing_raised { @item.quotePrefix = false }
76
- assert_equal(@item.quotePrefix, false)
77
- end
78
-
79
- def test_pivotButton
80
- assert_raise(ArgumentError) { @item.pivotButton = -1.1 }
81
- assert_nothing_raised { @item.pivotButton = false }
82
- assert_equal(@item.pivotButton, false)
83
- end
84
-
85
- def test_applyNumberFormat
86
- assert_raise(ArgumentError) { @item.applyNumberFormat = -1.1 }
87
- assert_nothing_raised { @item.applyNumberFormat = false }
88
- assert_equal(@item.applyNumberFormat, false)
89
- end
90
-
91
- def test_applyFont
92
- assert_raise(ArgumentError) { @item.applyFont = -1.1 }
93
- assert_nothing_raised { @item.applyFont = false }
94
- assert_equal(@item.applyFont, false)
95
- end
96
-
97
- def test_applyFill
98
- assert_raise(ArgumentError) { @item.applyFill = -1.1 }
99
- assert_nothing_raised { @item.applyFill = false }
100
- assert_equal(@item.applyFill, false)
101
- end
102
-
103
- def test_applyBorder
104
- assert_raise(ArgumentError) { @item.applyBorder = -1.1 }
105
- assert_nothing_raised { @item.applyBorder = false }
106
- assert_equal(@item.applyBorder, false)
107
- end
108
-
109
- def test_applyAlignment
110
- assert_raise(ArgumentError) { @item.applyAlignment = -1.1 }
111
- assert_nothing_raised { @item.applyAlignment = false }
112
- assert_equal(@item.applyAlignment, false)
113
- end
114
-
115
- def test_applyProtection
116
- assert_raise(ArgumentError) { @item.applyProtection = -1.1 }
117
- assert_nothing_raised { @item.applyProtection = false }
118
- assert_equal(@item.applyProtection, false)
119
- end
120
-
121
- end
@@ -1,68 +0,0 @@
1
- require 'test/unit'
2
- require 'axlsx.rb'
3
-
4
- class TestPackage < Test::Unit::TestCase
5
- def setup
6
- @package = Axlsx::Package.new
7
- ws = @package.workbook.add_worksheet
8
- chart = ws.add_chart Axlsx::Pie3DChart
9
- chart.add_series :data=>[1,2,3], :labels=>["a", "b", "c"]
10
- @fname = 'axlsx_test_serialization.xlsx'
11
-
12
- end
13
-
14
- def test_default_objects_are_created
15
- assert(@package.instance_values["app"].is_a?(Axlsx::App), 'App object not created')
16
- assert(@package.instance_values["core"].is_a?(Axlsx::Core), 'Core object not created')
17
- assert(@package.workbook.is_a?(Axlsx::Workbook), 'Workbook object not created')
18
- assert(Axlsx::Package.new.workbook.worksheets.size == 0, 'Workbook should not have sheets by default')
19
- end
20
-
21
- def test_serialization
22
- fname = 'axlsx_test_serialization.xlsx'
23
- assert_nothing_raised do
24
- begin
25
- z= @package.serialize(@fname)
26
- zf = Zip::ZipFile.open(@fname)
27
- @package.send(:parts).each{ |part| zf.get_entry(part[:entry]) }
28
- File.delete(@fname)
29
- rescue Errno::EACCES
30
- puts "WARNING:: test_serialization requires write access."
31
- end
32
- end
33
- end
34
-
35
- def test_validation
36
- assert_equal(@package.validate.size, 0, @package.validate)
37
- #how to test for failure? the internal validations on the models are so strict I cant break anthing.....
38
- end
39
-
40
- def test_parts
41
- p = @package.send(:parts)
42
- p.each do |part|
43
- #all parts must have :doc, :entry, :schema
44
- assert(part.keys.size == 3 && part.keys.reject{ |k| [:doc, :entry, :schema].include? k}.empty?)
45
- end
46
- #all parts have an entry
47
- assert_equal(p.select{ |part| part[:entry] =~ /_rels\/\.rels/ }.size, 1, "rels missing")
48
- assert_equal(p.select{ |part| part[:entry] =~ /docProps\/core\.xml/ }.size, 1, "core missing")
49
- assert_equal(p.select{ |part| part[:entry] =~ /docProps\/app\.xml/ }.size, 1, "app missing")
50
- assert_equal(p.select{ |part| part[:entry] =~ /xl\/_rels\/workbook\.xml\.rels/ }.size, 1, "workbook rels missing")
51
- assert_equal(p.select{ |part| part[:entry] =~ /xl\/workbook\.xml/ }.size, 1, "workbook missing")
52
- assert_equal(p.select{ |part| part[:entry] =~ /\[Content_Types\]\.xml/ }.size, 1, "content types missing")
53
- assert_equal(p.select{ |part| part[:entry] =~ /xl\/styles\.xml/ }.size, 1, "styles missin")
54
- assert_equal(p.select{ |part| part[:entry] =~ /xl\/drawings\/_rels\/drawing\d\.xml\.rels/ }.size, @package.workbook.drawings.size, "one or more drawing rels missing")
55
- assert_equal(p.select{ |part| part[:entry] =~ /xl\/drawings\/drawing\d\.xml/ }.size, @package.workbook.drawings.size, "one or more drawings missing")
56
- assert_equal(p.select{ |part| part[:entry] =~ /xl\/charts\/chart\d\.xml/ }.size, @package.workbook.charts.size, "one or more charts missing")
57
- assert_equal(p.select{ |part| part[:entry] =~ /xl\/worksheets\/sheet\d\.xml/ }.size, @package.workbook.worksheets.size, "one or more sheet missing")
58
- assert_equal(p.select{ |part| part[:entry] =~ /xl\/worksheets\/_rels\/sheet\d\.xml\.rels/ }.size, @package.workbook.worksheets.size, "one or more sheet rels missing")
59
-
60
- #no mystery parts
61
- assert_equal(p.size, 12)
62
-
63
- end
64
-
65
- def test_workbook_is_a_workbook
66
- assert @package.workbook.is_a? Axlsx::Workbook
67
- end
68
- end
@@ -1,66 +0,0 @@
1
- require 'test/unit'
2
- require 'axlsx.rb'
3
- class TestSimpleTypedList < Test::Unit::TestCase
4
- def setup
5
- @list = Axlsx::SimpleTypedList.new Fixnum
6
- end
7
-
8
- def teardown
9
- end
10
-
11
- def test_type_is_a_class_or_array_of_class
12
- assert_nothing_raised { Axlsx::SimpleTypedList.new Integer }
13
- assert_nothing_raised { Axlsx::SimpleTypedList.new [Integer,String] }
14
- assert_raise(ArgumentError) { Axlsx::SimpleTypedList.new }
15
- assert_raise(ArgumentError) { Axlsx::SimpleTypedList.new "1" }
16
- assert_raise(ArgumentError) { Axlsx::SimpleTypedList.new [Integer, "Class"] }
17
- end
18
-
19
- def test_indexed_based_assignment
20
- #should not allow nil assignment
21
- assert_raise(ArgumentError) { @list[0] = nil }
22
- assert_raise(ArgumentError) { @list[0] = "1" }
23
- assert_nothing_raised { @list[0] = 1 }
24
- end
25
-
26
- def test_concat_assignment
27
- assert_raise(ArgumentError) { @list << nil }
28
- assert_raise(ArgumentError) { @list << "1" }
29
- assert_nothing_raised { @list << 1 }
30
- end
31
-
32
- def test_concat_should_return_index
33
- assert( @list.size == 0 )
34
- assert( @list << 1 == 0 )
35
- assert( @list << 2 == 1 )
36
- @list.delete_at 0
37
- assert( @list << 3 == 1 )
38
- assert( @list.index(2) == 0 )
39
- end
40
-
41
- def test_push_should_return_index
42
- assert( @list.push(1) == 0 )
43
- assert( @list.push(2) == 1 )
44
- @list.delete_at 0
45
- assert( @list.push(3) == 1 )
46
- assert( @list.index(2) == 0 )
47
- end
48
-
49
- def test_locking
50
- @list.push 1
51
- @list.push 2
52
- @list.push 3
53
- @list.lock
54
-
55
- assert_raise(ArgumentError) { @list.delete 1 }
56
- assert_raise(ArgumentError) { @list.delete_at 1 }
57
- assert_raise(ArgumentError) { @list.delete_at 2 }
58
- @list.push 4
59
- assert_nothing_raised { @list.delete_at 3 }
60
- @list.unlock
61
- #ignore garbage
62
- assert_nothing_raised { @list.delete 0 }
63
- assert_nothing_raised { @list.delete 9 }
64
- end
65
-
66
- end