writeexcel 0.1.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (143) hide show
  1. data/README +26 -31
  2. data/examples/a_simple.rb +42 -42
  3. data/examples/{autofilters.rb → autofilter.rb} +264 -266
  4. data/examples/bigfile.rb +29 -0
  5. data/examples/chart_area.rb +120 -0
  6. data/examples/chart_bar.rb +119 -0
  7. data/examples/chart_column.rb +119 -0
  8. data/examples/chart_line.rb +119 -0
  9. data/examples/chart_pie.rb +107 -0
  10. data/examples/chart_scatter.rb +120 -0
  11. data/examples/chart_stock.rb +147 -0
  12. data/examples/copyformat.rb +51 -51
  13. data/examples/data_validate.rb +278 -278
  14. data/examples/date_time.rb +86 -86
  15. data/examples/defined_name.rb +31 -0
  16. data/examples/demo.rb +120 -118
  17. data/examples/diag_border.rb +35 -35
  18. data/examples/formats.rb +489 -489
  19. data/examples/header.rb +136 -136
  20. data/examples/hidden.rb +28 -28
  21. data/examples/hyperlink.rb +42 -42
  22. data/examples/images.rb +52 -52
  23. data/examples/merge1.rb +39 -39
  24. data/examples/merge2.rb +44 -44
  25. data/examples/merge3.rb +65 -65
  26. data/examples/merge4.rb +82 -82
  27. data/examples/merge5.rb +79 -79
  28. data/examples/properties.rb +33 -0
  29. data/examples/properties_jp.rb +32 -0
  30. data/examples/protection.rb +46 -46
  31. data/examples/regions.rb +52 -52
  32. data/examples/repeat.rb +42 -42
  33. data/examples/stats.rb +75 -75
  34. data/examples/stocks.rb +80 -80
  35. data/examples/tab_colors.rb +30 -30
  36. data/examples/write_arrays.rb +82 -0
  37. data/lib/writeexcel.rb +1134 -18
  38. data/lib/writeexcel/biffwriter.rb +273 -260
  39. data/lib/writeexcel/chart.rb +2306 -217
  40. data/lib/writeexcel/charts/area.rb +152 -0
  41. data/lib/writeexcel/charts/bar.rb +177 -0
  42. data/lib/writeexcel/charts/column.rb +156 -0
  43. data/lib/writeexcel/charts/external.rb +61 -0
  44. data/lib/writeexcel/charts/line.rb +152 -0
  45. data/lib/writeexcel/charts/pie.rb +169 -0
  46. data/lib/writeexcel/charts/scatter.rb +192 -0
  47. data/lib/writeexcel/charts/stock.rb +211 -0
  48. data/lib/writeexcel/excelformulaparser.rb +208 -195
  49. data/lib/writeexcel/format.rb +1697 -1108
  50. data/lib/writeexcel/formula.rb +1050 -986
  51. data/lib/writeexcel/olewriter.rb +322 -322
  52. data/lib/writeexcel/properties.rb +251 -250
  53. data/lib/writeexcel/storage_lite.rb +968 -0
  54. data/lib/writeexcel/workbook.rb +3294 -2630
  55. data/lib/writeexcel/worksheet.rb +9012 -6377
  56. data/test/excelfile/Chart1.xls +0 -0
  57. data/test/excelfile/Chart2.xls +0 -0
  58. data/test/excelfile/Chart3.xls +0 -0
  59. data/test/excelfile/Chart4.xls +0 -0
  60. data/test/excelfile/Chart5.xls +0 -0
  61. data/test/perl_output/Chart1.xls.data +0 -0
  62. data/test/perl_output/Chart2.xls.data +0 -0
  63. data/test/perl_output/Chart3.xls.data +0 -0
  64. data/test/perl_output/Chart4.xls.data +0 -0
  65. data/test/perl_output/Chart5.xls.data +0 -0
  66. data/test/perl_output/a_simple.xls +0 -0
  67. data/test/perl_output/autofilter.xls +0 -0
  68. data/test/perl_output/chart_area.xls +0 -0
  69. data/test/perl_output/chart_bar.xls +0 -0
  70. data/test/perl_output/chart_column.xls +0 -0
  71. data/test/perl_output/chart_line.xls +0 -0
  72. data/test/perl_output/data_validate.xls +0 -0
  73. data/test/perl_output/date_time.xls +0 -0
  74. data/test/perl_output/demo.xls +0 -0
  75. data/test/perl_output/demo101.bin +0 -0
  76. data/test/perl_output/demo201.bin +0 -0
  77. data/test/perl_output/demo301.bin +0 -0
  78. data/test/perl_output/demo401.bin +0 -0
  79. data/test/perl_output/demo501.bin +0 -0
  80. data/test/perl_output/diag_border.xls +0 -0
  81. data/test/perl_output/headers.xls +0 -0
  82. data/test/perl_output/hyperlink.xls +0 -0
  83. data/test/perl_output/images.xls +0 -0
  84. data/test/perl_output/merge1.xls +0 -0
  85. data/test/perl_output/merge2.xls +0 -0
  86. data/test/perl_output/merge3.xls +0 -0
  87. data/test/perl_output/merge4.xls +0 -0
  88. data/test/perl_output/merge5.xls +0 -0
  89. data/test/perl_output/protection.xls +0 -0
  90. data/test/perl_output/regions.xls +0 -0
  91. data/test/perl_output/stats.xls +0 -0
  92. data/test/perl_output/stocks.xls +0 -0
  93. data/test/perl_output/tab_colors.xls +0 -0
  94. data/test/perl_output/unicode_cyrillic.xls +0 -0
  95. data/test/perl_output/workbook1.xls +0 -0
  96. data/test/perl_output/workbook2.xls +0 -0
  97. data/test/tc_all.rb +32 -31
  98. data/test/tc_biff.rb +104 -104
  99. data/test/tc_chart.rb +22 -22
  100. data/test/tc_example_match.rb +1944 -1280
  101. data/test/tc_format.rb +1254 -1267
  102. data/test/tc_formula.rb +63 -63
  103. data/test/tc_ole.rb +110 -110
  104. data/test/tc_storage_lite.rb +149 -0
  105. data/test/tc_workbook.rb +140 -115
  106. data/test/tc_worksheet.rb +115 -115
  107. data/test/test_00_IEEE_double.rb +14 -14
  108. data/test/test_01_add_worksheet.rb +12 -12
  109. data/test/test_02_merge_formats.rb +58 -58
  110. data/test/test_04_dimensions.rb +397 -397
  111. data/test/test_05_rows.rb +182 -182
  112. data/test/test_06_extsst.rb +80 -80
  113. data/test/test_11_date_time.rb +484 -484
  114. data/test/test_12_date_only.rb +506 -506
  115. data/test/test_13_date_seconds.rb +486 -486
  116. data/test/test_21_escher.rb +642 -629
  117. data/test/test_22_mso_drawing_group.rb +750 -739
  118. data/test/test_23_note.rb +78 -78
  119. data/test/test_24_txo.rb +80 -80
  120. data/test/test_25_position_object.rb +82 -0
  121. data/test/test_26_autofilter.rb +327 -327
  122. data/test/test_27_autofilter.rb +144 -144
  123. data/test/test_28_autofilter.rb +174 -174
  124. data/test/test_29_process_jpg.rb +681 -131
  125. data/test/test_30_validation_dval.rb +82 -82
  126. data/test/test_31_validation_dv_strings.rb +131 -131
  127. data/test/test_32_validation_dv_formula.rb +211 -211
  128. data/test/test_40_property_types.rb +191 -191
  129. data/test/test_41_properties.rb +238 -238
  130. data/test/test_42_set_properties.rb +442 -419
  131. data/test/test_50_name_stored.rb +305 -0
  132. data/test/test_51_name_print_area.rb +363 -0
  133. data/test/test_52_name_print_titles.rb +460 -0
  134. data/test/test_53_autofilter.rb +209 -0
  135. data/test/test_60_chart_generic.rb +576 -0
  136. data/test/test_61_chart_subclasses.rb +97 -0
  137. data/test/test_62_chart_formats.rb +270 -0
  138. data/test/test_63_chart_area_formats.rb +647 -0
  139. data/test/test_chartex.rb +35 -0
  140. data/test/ts_all.rb +46 -34
  141. data/writeexcel.gemspec +18 -0
  142. data/writeexcel.rdoc +583 -0
  143. metadata +162 -108
data/test/tc_formula.rb CHANGED
@@ -1,63 +1,63 @@
1
- $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
2
-
3
- require "test/unit"
4
- require "writeexcel"
5
-
6
- class TC_Formula < Test::Unit::TestCase
7
-
8
- def setup
9
- @formula = Formula.new(0)
10
- end
11
-
12
- def test_scan
13
- # scan must return array of token info
14
- string01 = '1 + 2 * LEN("String")'
15
- expected01 = [
16
- [:NUMBER, '1'],
17
- ['+', '+'],
18
- [:NUMBER, '2'],
19
- ['*', '*'],
20
- [:FUNC, 'LEN'],
21
- ['(', '('],
22
- [:STRING, '"String"'],
23
- [')', ')'],
24
- [:EOL, nil]
25
- ]
26
- assert_kind_of(Array, @formula.scan(string01))
27
- assert_equal(expected01, @formula.scan(string01))
28
-
29
- string02 = 'IF(A1>=0,SIN(0),COS(90))'
30
- expected02 = [
31
- [:FUNC, 'IF'],
32
- ['(', '('],
33
- [:REF2D, 'A1'],
34
- [:GE, '>='],
35
- [:NUMBER, '0'],
36
- [',', ','],
37
- [:FUNC, 'SIN'],
38
- ['(', '('],
39
- [:NUMBER, '0'],
40
- [')', ')'],
41
- [',', ','],
42
- [:FUNC, 'COS'],
43
- ['(', '('],
44
- [:NUMBER, '90'],
45
- [')', ')'],
46
- [')', ')'],
47
- [:EOL, nil]
48
- ]
49
- assert_kind_of(Array, @formula.scan(string02))
50
- assert_equal(expected02, @formula.scan(string02))
51
- end
52
-
53
- def test_reverse
54
- testcase = [
55
- [ [0,1,2,3,4], [0,[1,[2,3,[4]]]] ],
56
- [ [0,1,2,3,4,5], [[0,1,[2,3]],[4,5]] ]
57
- ]
58
- testcase.each do |t|
59
- assert_equal(t[0], @formula.reverse(t[1]))
60
- end
61
- end
62
-
63
- end
1
+ $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
2
+
3
+ require "test/unit"
4
+ require "writeexcel"
5
+
6
+ class TC_Formula < Test::Unit::TestCase
7
+
8
+ def setup
9
+ @formula = Formula.new(0)
10
+ end
11
+
12
+ def test_scan
13
+ # scan must return array of token info
14
+ string01 = '1 + 2 * LEN("String")'
15
+ expected01 = [
16
+ [:NUMBER, '1'],
17
+ ['+', '+'],
18
+ [:NUMBER, '2'],
19
+ ['*', '*'],
20
+ [:FUNC, 'LEN'],
21
+ ['(', '('],
22
+ [:STRING, '"String"'],
23
+ [')', ')'],
24
+ [:EOL, nil]
25
+ ]
26
+ assert_kind_of(Array, @formula.scan(string01))
27
+ assert_equal(expected01, @formula.scan(string01))
28
+
29
+ string02 = 'IF(A1>=0,SIN(0),COS(90))'
30
+ expected02 = [
31
+ [:FUNC, 'IF'],
32
+ ['(', '('],
33
+ [:REF2D, 'A1'],
34
+ [:GE, '>='],
35
+ [:NUMBER, '0'],
36
+ [',', ','],
37
+ [:FUNC, 'SIN'],
38
+ ['(', '('],
39
+ [:NUMBER, '0'],
40
+ [')', ')'],
41
+ [',', ','],
42
+ [:FUNC, 'COS'],
43
+ ['(', '('],
44
+ [:NUMBER, '90'],
45
+ [')', ')'],
46
+ [')', ')'],
47
+ [:EOL, nil]
48
+ ]
49
+ assert_kind_of(Array, @formula.scan(string02))
50
+ assert_equal(expected02, @formula.scan(string02))
51
+ end
52
+
53
+ def test_reverse
54
+ testcase = [
55
+ [ [0,1,2,3,4], [0,[1,[2,3,[4]]]] ],
56
+ [ [0,1,2,3,4,5], [[0,1,[2,3]],[4,5]] ]
57
+ ]
58
+ testcase.each do |t|
59
+ assert_equal(t[0], @formula.reverse(t[1]))
60
+ end
61
+ end
62
+
63
+ end
data/test/tc_ole.rb CHANGED
@@ -1,110 +1,110 @@
1
- $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
2
-
3
- require "test/unit"
4
- require "writeexcel"
5
-
6
- class TC_OLE < Test::Unit::TestCase
7
-
8
- def setup
9
- t = Time.now.strftime("%Y%m%d")
10
- path = "temp#{t}-#{$$}-#{rand(0x100000000).to_s(36)}"
11
- @file = File.join(Dir.tmpdir, path)
12
- @ole = OLEWriter.new(@file)
13
- end
14
-
15
- def test_constructor
16
- assert_kind_of(OLEWriter, @ole)
17
- end
18
-
19
- def test_constants
20
- assert_equal(7087104, OLEWriter::MaxSize)
21
- assert_equal(4096, OLEWriter::BlockSize)
22
- assert_equal(512, OLEWriter::BlockDiv)
23
- assert_equal(127, OLEWriter::ListBlocks)
24
- end
25
-
26
- def test_calculate_sizes
27
- assert_respond_to(@ole, :calculate_sizes)
28
- assert_nothing_raised{ @ole.calculate_sizes }
29
- assert_equal(0, @ole.big_blocks)
30
- assert_equal(1, @ole.list_blocks)
31
- assert_equal(0, @ole.root_start)
32
- end
33
-
34
- def test_set_size_too_big
35
- assert(!@ole.set_size(999999999))
36
- end
37
-
38
- def test_book_size_large
39
- assert_nothing_raised{ @ole.set_size(8192) }
40
- assert_equal(8192, @ole.book_size)
41
- end
42
-
43
- def test_book_size_small
44
- assert_nothing_raised{ @ole.set_size(2048) }
45
- assert_equal(4096, @ole.book_size)
46
- end
47
-
48
- def test_biff_size
49
- assert_nothing_raised{ @ole.set_size(2048) }
50
- assert_equal(2048, @ole.biff_size)
51
- end
52
-
53
- def test_size_allowed
54
- assert_nothing_raised{ @ole.set_size }
55
- assert_equal(true, @ole.size_allowed)
56
- end
57
-
58
- def test_big_block_size_default
59
- assert_nothing_raised{ @ole.set_size }
60
- assert_nothing_raised{ @ole.calculate_sizes }
61
- assert_equal(8, @ole.big_blocks, "Bad big block size")
62
- end
63
-
64
- def test_big_block_size_rounded_up
65
- assert_nothing_raised{ @ole.set_size(4099) }
66
- assert_nothing_raised{ @ole.calculate_sizes }
67
- assert_equal(9, @ole.big_blocks, "Bad big block size")
68
- end
69
-
70
- def test_list_block_size
71
- assert_nothing_raised{ @ole.set_size }
72
- assert_nothing_raised{ @ole.calculate_sizes }
73
- assert_equal(1, @ole.list_blocks, "Bad list block size")
74
- end
75
-
76
- def test_root_start_size_default
77
- assert_nothing_raised{ @ole.set_size }
78
- assert_nothing_raised{ @ole.calculate_sizes }
79
- assert_equal(8, @ole.big_blocks, "Bad root start size")
80
- end
81
-
82
- def test_root_start_size_rounded_up
83
- assert_nothing_raised{ @ole.set_size(4099) }
84
- assert_nothing_raised{ @ole.calculate_sizes }
85
- assert_equal(9, @ole.big_blocks, "Bad root start size")
86
- end
87
-
88
- def test_write_header
89
- assert_nothing_raised{ @ole.write_header }
90
- #assert_nothing_raised{ @ole.close }
91
- #assert_equal(512, File.size(@file))
92
- end
93
-
94
- def test_write_big_block_depot
95
- assert_nothing_raised{ @ole.write_big_block_depot }
96
- #assert_nothing_raised{ @ole.close }
97
- #assert_equal(8, File.size(@file))
98
- end
99
-
100
- def test_write_property_storage_size
101
- assert_nothing_raised{ @ole.write_property_storage }
102
- #assert_nothing_raised{ @ole.close }
103
- #assert_equal(512, File.size(@file))
104
- end
105
-
106
- def teardown
107
- @ole.close rescue nil
108
- File.unlink(@file) if File.exists?(@file)
109
- end
110
- end
1
+ $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
2
+
3
+ require "test/unit"
4
+ require "writeexcel"
5
+
6
+ class TC_OLE < Test::Unit::TestCase
7
+
8
+ def setup
9
+ t = Time.now.strftime("%Y%m%d")
10
+ path = "temp#{t}-#{$$}-#{rand(0x100000000).to_s(36)}"
11
+ @file = File.join(Dir.tmpdir, path)
12
+ @ole = OLEWriter.new(@file)
13
+ end
14
+
15
+ def test_constructor
16
+ assert_kind_of(OLEWriter, @ole)
17
+ end
18
+
19
+ def test_constants
20
+ assert_equal(7087104, OLEWriter::MaxSize)
21
+ assert_equal(4096, OLEWriter::BlockSize)
22
+ assert_equal(512, OLEWriter::BlockDiv)
23
+ assert_equal(127, OLEWriter::ListBlocks)
24
+ end
25
+
26
+ def test_calculate_sizes
27
+ assert_respond_to(@ole, :calculate_sizes)
28
+ assert_nothing_raised{ @ole.calculate_sizes }
29
+ assert_equal(0, @ole.big_blocks)
30
+ assert_equal(1, @ole.list_blocks)
31
+ assert_equal(0, @ole.root_start)
32
+ end
33
+
34
+ def test_set_size_too_big
35
+ assert(!@ole.set_size(999999999))
36
+ end
37
+
38
+ def test_book_size_large
39
+ assert_nothing_raised{ @ole.set_size(8192) }
40
+ assert_equal(8192, @ole.book_size)
41
+ end
42
+
43
+ def test_book_size_small
44
+ assert_nothing_raised{ @ole.set_size(2048) }
45
+ assert_equal(4096, @ole.book_size)
46
+ end
47
+
48
+ def test_biff_size
49
+ assert_nothing_raised{ @ole.set_size(2048) }
50
+ assert_equal(2048, @ole.biff_size)
51
+ end
52
+
53
+ def test_size_allowed
54
+ assert_nothing_raised{ @ole.set_size }
55
+ assert_equal(true, @ole.size_allowed)
56
+ end
57
+
58
+ def test_big_block_size_default
59
+ assert_nothing_raised{ @ole.set_size }
60
+ assert_nothing_raised{ @ole.calculate_sizes }
61
+ assert_equal(8, @ole.big_blocks, "Bad big block size")
62
+ end
63
+
64
+ def test_big_block_size_rounded_up
65
+ assert_nothing_raised{ @ole.set_size(4099) }
66
+ assert_nothing_raised{ @ole.calculate_sizes }
67
+ assert_equal(9, @ole.big_blocks, "Bad big block size")
68
+ end
69
+
70
+ def test_list_block_size
71
+ assert_nothing_raised{ @ole.set_size }
72
+ assert_nothing_raised{ @ole.calculate_sizes }
73
+ assert_equal(1, @ole.list_blocks, "Bad list block size")
74
+ end
75
+
76
+ def test_root_start_size_default
77
+ assert_nothing_raised{ @ole.set_size }
78
+ assert_nothing_raised{ @ole.calculate_sizes }
79
+ assert_equal(8, @ole.big_blocks, "Bad root start size")
80
+ end
81
+
82
+ def test_root_start_size_rounded_up
83
+ assert_nothing_raised{ @ole.set_size(4099) }
84
+ assert_nothing_raised{ @ole.calculate_sizes }
85
+ assert_equal(9, @ole.big_blocks, "Bad root start size")
86
+ end
87
+
88
+ def test_write_header
89
+ assert_nothing_raised{ @ole.write_header }
90
+ #assert_nothing_raised{ @ole.close }
91
+ #assert_equal(512, File.size(@file))
92
+ end
93
+
94
+ def test_write_big_block_depot
95
+ assert_nothing_raised{ @ole.write_big_block_depot }
96
+ #assert_nothing_raised{ @ole.close }
97
+ #assert_equal(8, File.size(@file))
98
+ end
99
+
100
+ def test_write_property_storage_size
101
+ assert_nothing_raised{ @ole.write_property_storage }
102
+ #assert_nothing_raised{ @ole.close }
103
+ #assert_equal(512, File.size(@file))
104
+ end
105
+
106
+ def teardown
107
+ @ole.close rescue nil
108
+ File.unlink(@file) if File.exists?(@file)
109
+ end
110
+ end
@@ -0,0 +1,149 @@
1
+ $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
2
+
3
+ require "test/unit"
4
+ require "writeexcel/storage_lite"
5
+ require 'stringio'
6
+
7
+ =begin
8
+ def compare_file(expected, target)
9
+ fh_e = File.open(expected, "r")
10
+ fh_t = File.open(target, "r")
11
+ while true do
12
+ e1 = fh_e.read(1)
13
+ t1 = fh_t.read(1)
14
+ if e1.nil?
15
+ assert( t1.nil?, "#{expexted} is EOF but #{target} is NOT EOF.")
16
+ break
17
+ elsif t1.nil?
18
+ assert( e1.nil?, '#{target} is EOF but #{expected} is NOT EOF.')
19
+ break
20
+ end
21
+ assert_equal(e1, t1, sprintf(" #{expected} = '%s' but #{target} = '%s'", e1, t1))
22
+ break
23
+ end
24
+ fh_e.close
25
+ fh_t.close
26
+ end
27
+ =end
28
+
29
+ class TC_OLEStorageLite < Test::Unit::TestCase
30
+ TEST_DIR = File.expand_path(File.dirname(__FILE__))
31
+ PERL_OUTDIR = File.join(TEST_DIR, 'perl_output')
32
+ EXCEL_OUTDIR = File.join(TEST_DIR, 'excelfile')
33
+
34
+ def setup
35
+ @ole = OLEStorageLite.new
36
+ end
37
+
38
+ def teardown
39
+ end
40
+
41
+ def test_olestoragelite_new
42
+ ole = OLEStorageLite.new
43
+ assert_nil(ole.file)
44
+
45
+ io = StringIO.new
46
+ ole = OLEStorageLite.new(io)
47
+ assert_equal(io, ole.file)
48
+
49
+ file = 'test.ole'
50
+ ole = OLEStorageLite.new(file)
51
+ assert_equal(file, ole.file)
52
+
53
+ end
54
+
55
+ def test_asc2ucs
56
+ result = @ole.asc2ucs('Root Entry')
57
+ target = %w(
58
+ 52 00 6F 00 6F 00 74 00 20 00 45 00 6E 00 74 00 72 00 79 00
59
+ ).join(" ")
60
+ assert_equal(target, unpack_record(result))
61
+ end
62
+
63
+ def test_ucs2asc
64
+ strings = [
65
+ 'Root Entry',
66
+ ''
67
+ ]
68
+ strings.each do |str|
69
+ result = @ole.ucs2asc(@ole.asc2ucs(str))
70
+ assert_equal(str, result)
71
+ end
72
+ end
73
+
74
+ def unpack_record(data)
75
+ data.unpack('C*').map! {|c| sprintf("%02X", c) }.join(' ')
76
+ end
77
+
78
+ end
79
+
80
+ class TC_OLEStorageLitePPSFile < Test::Unit::TestCase
81
+ def setup
82
+ end
83
+
84
+ def teardown
85
+ end
86
+
87
+ def test_constructor
88
+ data = [
89
+ { :name => 'name', :data => 'data' },
90
+ { :name => '', :data => 'data' },
91
+ { :name => 'name', :data => '' },
92
+ { :name => '', :data => '' },
93
+ ]
94
+ data.each do |d|
95
+ olefile = OLEStorageLitePPSFile.new(d[:name])
96
+ assert_equal(d[:name], olefile.name)
97
+ end
98
+ data.each do |d|
99
+ olefile = OLEStorageLitePPSFile.new(d[:name], d[:data])
100
+ assert_equal(d[:name], olefile.name)
101
+ assert_equal(d[:data], olefile.data)
102
+ end
103
+ end
104
+
105
+ def test_append_no_file
106
+ olefile = OLEStorageLitePPSFile.new('name')
107
+ assert_equal('', olefile.data)
108
+
109
+ data = [ "data", "\r\n", "\r", "\n" ]
110
+ data.each do |d|
111
+ olefile = OLEStorageLitePPSFile.new('name')
112
+ olefile.append(d)
113
+ assert_equal(d, olefile.data)
114
+ end
115
+ end
116
+
117
+ def test_append_tempfile
118
+ data = [ "data", "\r\n", "\r", "\n" ]
119
+ data.each do |d|
120
+ olefile = OLEStorageLitePPSFile.new('name')
121
+ olefile.set_file
122
+ pps_file = olefile.pps_file
123
+
124
+ olefile.append(d)
125
+ pps_file.open
126
+ pps_file.binmode
127
+ assert_equal(d, pps_file.read)
128
+ end
129
+ end
130
+
131
+ def test_append_stringio
132
+ data = [ "data", "\r\n", "\r", "\n" ]
133
+ data.each do |d|
134
+ sio = StringIO.new
135
+ olefile = OLEStorageLitePPSFile.new('name')
136
+ olefile.set_file(sio)
137
+ pps_file = olefile.pps_file
138
+
139
+ olefile.append(d)
140
+ pps_file.rewind
141
+ assert_equal(d, pps_file.read)
142
+ end
143
+ end
144
+
145
+ def unpack_record(data)
146
+ data.unpack('C*').map! {|c| sprintf("%02X", c) }.join(' ')
147
+ end
148
+
149
+ end