writeexcel 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. data/.gitattributes +1 -1
  2. data/.gitignore +24 -24
  3. data/README.rdoc +34 -55
  4. data/VERSION +1 -1
  5. data/charts/chartex.rb +316 -316
  6. data/charts/demo1.rb +46 -46
  7. data/charts/demo2.rb +65 -65
  8. data/charts/demo3.rb +117 -117
  9. data/charts/demo4.rb +119 -119
  10. data/charts/demo5.rb +48 -48
  11. data/examples/a_simple.rb +43 -43
  12. data/examples/autofilter.rb +265 -265
  13. data/examples/bigfile.rb +30 -30
  14. data/examples/chart_area.rb +121 -121
  15. data/examples/chart_bar.rb +120 -120
  16. data/examples/chart_column.rb +120 -120
  17. data/examples/chart_line.rb +120 -120
  18. data/examples/chart_pie.rb +108 -108
  19. data/examples/chart_scatter.rb +121 -121
  20. data/examples/chart_stock.rb +148 -148
  21. data/examples/chess.rb +142 -142
  22. data/examples/colors.rb +129 -129
  23. data/examples/comments1.rb +27 -27
  24. data/examples/comments2.rb +352 -352
  25. data/examples/copyformat.rb +52 -52
  26. data/examples/data_validate.rb +279 -279
  27. data/examples/date_time.rb +87 -87
  28. data/examples/defined_name.rb +32 -32
  29. data/examples/demo.rb +124 -124
  30. data/examples/diag_border.rb +36 -36
  31. data/examples/formats.rb +490 -490
  32. data/examples/formula_result.rb +30 -30
  33. data/examples/header.rb +137 -137
  34. data/examples/hide_sheet.rb +29 -29
  35. data/examples/hyperlink.rb +43 -43
  36. data/examples/images.rb +63 -63
  37. data/examples/indent.rb +31 -31
  38. data/examples/merge1.rb +40 -40
  39. data/examples/merge2.rb +45 -45
  40. data/examples/merge3.rb +66 -66
  41. data/examples/merge4.rb +83 -83
  42. data/examples/merge5.rb +80 -80
  43. data/examples/merge6.rb +67 -67
  44. data/examples/outline.rb +255 -255
  45. data/examples/outline_collapsed.rb +209 -209
  46. data/examples/panes.rb +113 -113
  47. data/examples/properties.rb +34 -34
  48. data/examples/properties_jp.rb +33 -33
  49. data/examples/protection.rb +47 -47
  50. data/examples/regions.rb +53 -53
  51. data/examples/repeat.rb +43 -43
  52. data/examples/right_to_left.rb +27 -27
  53. data/examples/row_wrap.rb +53 -53
  54. data/examples/stats.rb +74 -74
  55. data/examples/stocks.rb +81 -81
  56. data/examples/tab_colors.rb +31 -31
  57. data/examples/utf8.rb +15 -15
  58. data/examples/write_arrays.rb +83 -83
  59. data/lib/writeexcel/biffwriter.rb +232 -232
  60. data/lib/writeexcel/caller_info.rb +12 -12
  61. data/lib/writeexcel/chart.rb +2190 -2177
  62. data/lib/writeexcel/charts/area.rb +154 -154
  63. data/lib/writeexcel/charts/bar.rb +177 -177
  64. data/lib/writeexcel/charts/column.rb +156 -156
  65. data/lib/writeexcel/charts/external.rb +66 -66
  66. data/lib/writeexcel/charts/line.rb +154 -154
  67. data/lib/writeexcel/charts/pie.rb +169 -169
  68. data/lib/writeexcel/charts/scatter.rb +192 -192
  69. data/lib/writeexcel/charts/stock.rb +213 -213
  70. data/lib/writeexcel/colors.rb +64 -64
  71. data/lib/writeexcel/compatibility.rb +0 -255
  72. data/lib/writeexcel/debug_info.rb +37 -33
  73. data/lib/writeexcel/excelformulaparser.rb +587 -587
  74. data/lib/writeexcel/format.rb +13 -4
  75. data/lib/writeexcel/formula.rb +26 -9
  76. data/lib/writeexcel/helper.rb +68 -64
  77. data/lib/writeexcel/olewriter.rb +311 -311
  78. data/lib/writeexcel/properties.rb +242 -240
  79. data/lib/writeexcel/storage_lite.rb +984 -978
  80. data/lib/writeexcel/workbook.rb +3210 -3192
  81. data/lib/writeexcel/worksheet.rb +143 -51
  82. data/lib/writeexcel/write_file.rb +44 -40
  83. data/lib/writeexcel.rb +1159 -1159
  84. data/test/helper.rb +31 -28
  85. data/test/perl_output/README +31 -31
  86. data/test/test_00_IEEE_double.rb +13 -13
  87. data/test/test_01_add_worksheet.rb +10 -10
  88. data/test/test_02_merge_formats.rb +53 -53
  89. data/test/test_04_dimensions.rb +392 -392
  90. data/test/test_05_rows.rb +179 -179
  91. data/test/test_06_extsst.rb +77 -77
  92. data/test/test_11_date_time.rb +479 -479
  93. data/test/test_12_date_only.rb +501 -501
  94. data/test/test_13_date_seconds.rb +481 -481
  95. data/test/test_21_escher.rb +637 -637
  96. data/test/test_22_mso_drawing_group.rb +745 -745
  97. data/test/test_23_note.rb +73 -73
  98. data/test/test_24_txo.rb +75 -75
  99. data/test/test_25_position_object.rb +84 -84
  100. data/test/test_26_autofilter.rb +314 -314
  101. data/test/test_27_autofilter.rb +131 -131
  102. data/test/test_28_autofilter.rb +161 -161
  103. data/test/test_29_process_jpg.rb +683 -683
  104. data/test/test_30_validation_dval.rb +77 -77
  105. data/test/test_31_validation_dv_strings.rb +126 -126
  106. data/test/test_32_validation_dv_formula.rb +206 -206
  107. data/test/test_40_property_types.rb +188 -188
  108. data/test/test_41_properties.rb +235 -235
  109. data/test/test_42_set_properties.rb +437 -437
  110. data/test/test_50_name_stored.rb +299 -299
  111. data/test/test_51_name_print_area.rb +357 -357
  112. data/test/test_52_name_print_titles.rb +454 -454
  113. data/test/test_53_autofilter.rb +203 -203
  114. data/test/test_60_chart_generic.rb +578 -578
  115. data/test/test_61_chart_subclasses.rb +95 -95
  116. data/test/test_62_chart_formats.rb +272 -272
  117. data/test/test_63_chart_area_formats.rb +649 -649
  118. data/test/test_biff.rb +75 -75
  119. data/test/test_compatibility.rb +12 -627
  120. data/test/test_example_match.rb +3144 -3144
  121. data/test/test_formula.rb +61 -61
  122. data/test/test_ole.rb +106 -106
  123. data/test/test_storage_lite.rb +125 -125
  124. data/test/test_workbook.rb +139 -139
  125. data/test/test_worksheet.rb +110 -110
  126. data/utils/add_magic_comment.rb +80 -80
  127. data/writeexcel.gemspec +4 -6
  128. data/writeexcel.rdoc +58 -15
  129. metadata +9 -6
  130. data/test/test_new_encoding.rb +0 -205
@@ -1,627 +1,12 @@
1
- # -*- coding: utf-8 -*-
2
- require 'helper'
3
- require 'nkf'
4
-
5
- class TC_Compatibility < Test::Unit::TestCase
6
- def setup
7
- ruby_18 do
8
- @kcode = $KCODE
9
- $KCODE = 'u'
10
- end
11
- end
12
-
13
- def teardown
14
- ruby_18 { $KCODE = @kcode }
15
- end
16
-
17
- def test_encoding
18
- # String#encoding -> Encoding::***
19
- str = 'あいう'
20
- utf8 = str
21
- # utf16le = NKF.nkf('-w16L0 -m0 -W', str)
22
- # utf16be = NKF.nkf('-w16B0 -m0 -W', str)
23
- assert_equal(Encoding::UTF_8, utf8.encoding)
24
-
25
- if RUBY_VERSION < "1.9"
26
- # String#encoding returns depending $KCODE
27
- # if string has not changed its encoding.
28
- str = 'abc'
29
- utf8 = str
30
- assert_equal(Encoding::UTF_8, utf8.encoding)
31
- end
32
- end
33
-
34
- def ascii_str_enc_ascii
35
- str = ["abc"].pack('a*').encode('ASCII')
36
- str.encode('ASCII') if RUBY_VERSION < "1.9"
37
- str
38
- end
39
-
40
- def test_ascii_str_enc_ascii_is_ascii_encoding
41
- assert_equal(Encoding::ASCII, ascii_str_enc_ascii.encoding)
42
- end
43
-
44
- def ascii_str_enc_binary
45
- str = ["abc"].pack('a*').encode('BINARY')
46
- str.encode('BINARY') if RUBY_VERSION < "1.9"
47
- str
48
- end
49
-
50
- def test_ascii_str_enc_binary_is_binary_encoding
51
- assert_equal(Encoding::BINARY, ascii_str_enc_binary.encoding)
52
- end
53
-
54
- def non_ascii_str_enc_binary
55
- str = [0x80].pack('v*')
56
- str.force_encoding('BINARY')
57
- str
58
- end
59
-
60
- def test_non_ascii_str_enc_binary
61
- assert_equal(Encoding::BINARY, non_ascii_str_enc_binary.encoding)
62
- end
63
-
64
- def ascii_str_enc_utf8
65
- "abc"
66
- end
67
-
68
- def test_ascii_str_enc_utf8_is_utf8_encoding
69
- assert_equal(Encoding::UTF_8, ascii_str_enc_utf8.encoding)
70
- end
71
-
72
- def non_ascii_str_enc_utf8
73
- 'あいう'
74
- end
75
-
76
- def test_non_ascii_str_enc_utf8
77
- assert_equal(Encoding::UTF_8, non_ascii_str_enc_utf8.encoding)
78
- end
79
-
80
- def ascii_str_enc_eucjp
81
- str = "abc".encode('EUCJP')
82
- str
83
- end
84
-
85
- def test_ascii_str_enc_eucjp_is_eucjp_encoding
86
- assert_equal(Encoding::EUCJP, ascii_str_enc_eucjp.encoding)
87
- end
88
-
89
- def non_ascii_str_enc_eucjp
90
- str = 'あいう'.encode('EUCJP')
91
- str
92
- end
93
-
94
- def test_non_ascii_str_enc_eucjp
95
- assert_equal(Encoding::EUCJP, non_ascii_str_enc_eucjp.encoding)
96
- end
97
-
98
- def ascii_str_enc_sjis
99
- str = "abc".encode('SJIS')
100
- str
101
- end
102
-
103
- def test_ascii_str_enc_sjis_is_sjis_encoding
104
- assert_equal(Encoding::SJIS, ascii_str_enc_sjis.encoding)
105
- end
106
-
107
- def non_ascii_str_enc_sjis
108
- str = 'あいう'.encode('SJIS')
109
- str
110
- end
111
-
112
- def test_non_ascii_str_enc_sjis
113
- assert_equal(Encoding::SJIS, non_ascii_str_enc_sjis.encoding)
114
- end
115
-
116
- def ascii_str_enc_utf16le
117
- str = NKF.nkf('-w16L0 -m0 -W', "abc")
118
- str.force_encoding('UTF_16LE') if RUBY_VERSION < "1.9"
119
- str
120
- end
121
-
122
- def test_ascii_str_enc_utf16le_is_utf16le_encoding
123
- assert_equal(Encoding::UTF_16LE, ascii_str_enc_utf16le.encoding)
124
- end
125
-
126
- def non_ascii_str_enc_utf16le
127
- str = NKF.nkf('-w16L0 -m0 -W', 'あいう')
128
- str.force_encoding('UTF_16LE') if RUBY_VERSION < "1.9"
129
- str
130
- end
131
-
132
- def test_non_ascii_str_enc_utf16le
133
- assert_equal(Encoding::UTF_16LE, non_ascii_str_enc_utf16le.encoding)
134
- end
135
-
136
- def ascii_str_enc_utf16be
137
- str = NKF.nkf('-w16B0 -m0 -W', "abc")
138
- str.force_encoding('UTF_16BE') if RUBY_VERSION < "1.9"
139
- str
140
- end
141
-
142
- def test_ascii_str_enc_utf16be_is_utf16be_encoding
143
- assert_equal(Encoding::UTF_16BE, ascii_str_enc_utf16be.encoding)
144
- end
145
-
146
- def non_ascii_str_enc_utf16be
147
- str = NKF.nkf('-w16B0 -m0 -W', 'あいう')
148
- str.force_encoding('UTF_16BE') if RUBY_VERSION < "1.9"
149
- str
150
- end
151
-
152
- def test_non_ascii_str_enc_utf16be
153
- assert_equal(Encoding::UTF_16BE, non_ascii_str_enc_utf16be.encoding)
154
- end
155
-
156
- def test_ascii_str_ascii_to_ascii
157
- str = ascii_str_enc_ascii
158
- assert_equal(Encoding::ASCII, str.encode('ASCII').encoding)
159
- end
160
-
161
- def test_ascii_str_ascii_to_binary
162
- str = ascii_str_enc_ascii
163
- assert_equal(Encoding::BINARY, str.encode('BINARY').encoding)
164
- end
165
-
166
- def test_ascii_str_ascii_to_utf8
167
- str = ascii_str_enc_ascii
168
- assert_raise(Encoding::ConverterNotFoundError){ str.encode('UTF_8') }
169
- end
170
-
171
- def test_ascii_str_ascii_to_eucjp
172
- str = ascii_str_enc_ascii
173
- assert_equal(Encoding::EUCJP, str.encode('EUCJP').encoding)
174
- end
175
-
176
- def test_ascii_str_ascii_to_sjis
177
- str = ascii_str_enc_ascii
178
- assert_equal(Encoding::SJIS, str.encode('SJIS').encoding)
179
- end
180
-
181
- def test_ascii_str_ascii_to_utf16le
182
- str = ascii_str_enc_ascii
183
- assert_raise(Encoding::ConverterNotFoundError){ str.encode('UTF_16LE') }
184
- end
185
-
186
- def test_ascii_str_ascii_to_utf16be
187
- str = ascii_str_enc_ascii
188
- assert_raise(Encoding::ConverterNotFoundError){ str.encode('UTF_16BE') }
189
- end
190
-
191
- def test_ascii_str_binary_to_ascii
192
- str = ascii_str_enc_binary
193
- assert_equal(Encoding::ASCII, str.encode('ASCII').encoding)
194
- end
195
-
196
- def test_non_ascii_str_binary_to_ascii
197
- str = non_ascii_str_enc_binary
198
- assert_raise(Encoding::UndefinedConversionError){ str.encode('ASCII') }
199
- end
200
-
201
- def test_ascii_str_binary_to_binary
202
- str = ascii_str_enc_binary
203
- assert_equal(Encoding::BINARY, str.encode('BINARY').encoding)
204
- end
205
-
206
- def test_non_ascii_str_binary_to_binary
207
- str = non_ascii_str_enc_binary
208
- assert_equal(Encoding::BINARY, str.encode('BINARY').encoding)
209
- end
210
-
211
- def test_ascii_str_binary_to_utf8
212
- str = ascii_str_enc_binary
213
- assert_raise(Encoding::ConverterNotFoundError){ str.encode('UTF_8') }
214
- end
215
-
216
- def test_non_ascii_str_binary_to_utf8
217
- str = non_ascii_str_enc_binary
218
- assert_raise(Encoding::ConverterNotFoundError,
219
- Encoding::UndefinedConversionError) { str.encode('UTF_8') }
220
- end
221
-
222
- def test_ascii_str_binary_to_eucjp
223
- str = ascii_str_enc_binary
224
- assert_equal(Encoding::EUCJP, str.encode('EUCJP').encoding)
225
- end
226
-
227
- def test_non_ascii_str_binary_to_eucjp
228
- str = non_ascii_str_enc_binary
229
- assert_raise(Encoding::ConverterNotFoundError,
230
- Encoding::UndefinedConversionError) { str.encode('EUCJP') }
231
- end
232
-
233
- def test_ascii_str_binary_to_sjis
234
- str = ascii_str_enc_binary
235
- assert_equal(Encoding::SJIS, str.encode('SJIS').encoding)
236
- end
237
-
238
- def test_non_ascii_str_binary_to_sjis
239
- str = non_ascii_str_enc_binary
240
- assert_raise(Encoding::ConverterNotFoundError,
241
- Encoding::UndefinedConversionError) { str.encode('SJIS') }
242
- end
243
-
244
- def test_ascii_str_binary_to_utf16le
245
- str = ascii_str_enc_binary
246
- assert_raise(Encoding::ConverterNotFoundError){ str.encode('UTF_16LE') }
247
- end
248
-
249
- def test_non_ascii_str_binary_to_utf16le
250
- str = non_ascii_str_enc_binary
251
- assert_raise(Encoding::ConverterNotFoundError) { str.encode('UTF_16LE') }
252
- end
253
-
254
- def test_ascii_str_binary_to_utf16be
255
- str = ascii_str_enc_binary
256
- assert_raise(Encoding::ConverterNotFoundError){ str.encode('UTF_16BE') }
257
- end
258
-
259
- def test_non_ascii_str_binary_to_utf16be
260
- str = non_ascii_str_enc_binary
261
- assert_raise(Encoding::ConverterNotFoundError) { str.encode('UTF_16BE') }
262
- end
263
-
264
- def test_ascii_str_utf8_to_ascii
265
- str = ascii_str_enc_utf8
266
- assert_equal(Encoding::ASCII, str.encode('ASCII').encoding)
267
- end
268
-
269
- def test_non_ascii_str_utf8_to_ascii
270
- str = non_ascii_str_enc_utf8
271
- assert_raise(Encoding::UndefinedConversionError) { str.encode('ASCII') }
272
- end
273
-
274
- def test_ascii_str_utf8_to_binary
275
- str = ascii_str_enc_utf8
276
- assert_equal(Encoding::BINARY, str.encode('BINARY').encoding)
277
- end
278
-
279
- def test_non_ascii_str_utf8_to_binary
280
- str = non_ascii_str_enc_utf8
281
- assert_raise(Encoding::UndefinedConversionError) { str.encode('BINARY') }
282
- end
283
-
284
- def test_ascii_str_utf8_to_utf8
285
- str = ascii_str_enc_utf8
286
- assert_raise(Encoding::ConverterNotFoundError){ str.encode('UTF_8') }
287
- end
288
-
289
- def test_non_ascii_str_utf8_to_utf8
290
- str = non_ascii_str_enc_utf8
291
- assert_raise(Encoding::ConverterNotFoundError) { str.encode('UTF_8') }
292
- end
293
-
294
- def test_ascii_str_utf8_to_eucjp
295
- str = ascii_str_enc_utf8
296
- assert_equal(Encoding::EUCJP, str.encode('EUCJP').encoding)
297
- end
298
-
299
- def test_non_ascii_str_utf8_to_eucjp
300
- str = non_ascii_str_enc_utf8
301
- assert_equal(Encoding::EUCJP, str.encode('EUCJP').encoding)
302
- end
303
-
304
- def test_ascii_str_utf8_to_sjis
305
- str = ascii_str_enc_utf8
306
- assert_equal(Encoding::SJIS, str.encode('SJIS').encoding)
307
- end
308
-
309
- def test_non_ascii_str_utf8_to_sjis
310
- str = non_ascii_str_enc_utf8
311
- assert_equal(Encoding::SJIS, str.encode('SJIS').encoding)
312
- end
313
-
314
- def test_ascii_str_utf8_to_utf16le
315
- str = ascii_str_enc_utf8
316
- assert_raise(Encoding::ConverterNotFoundError){ str.encode('UTF_16LE') }
317
- end
318
-
319
- def test_non_ascii_str_utf8_to_utf16le
320
- str = non_ascii_str_enc_utf8
321
- assert_raise(Encoding::ConverterNotFoundError) { str.encode('UTF_16LE') }
322
- end
323
-
324
- def test_ascii_str_utf8_to_utf16be
325
- str = ascii_str_enc_utf8
326
- assert_raise(Encoding::ConverterNotFoundError){ str.encode('UTF_16BE') }
327
- end
328
-
329
- def test_non_ascii_str_utf8_to_utf16be
330
- str = non_ascii_str_enc_utf8
331
- assert_raise(Encoding::ConverterNotFoundError) { str.encode('UTF_16BE') }
332
- end
333
-
334
- def test_ascii_str_eucjp_to_ascii
335
- str = ascii_str_enc_eucjp
336
- assert_equal(Encoding::ASCII, str.encode('ASCII').encoding)
337
- end
338
-
339
- def test_non_ascii_str_eucjp_to_ascii
340
- str = non_ascii_str_enc_eucjp
341
- assert_raise(Encoding::UndefinedConversionError) { str.encode('ASCII') }
342
- end
343
-
344
- def test_ascii_str_eucjp_to_binary
345
- str = ascii_str_enc_eucjp
346
- assert_equal(Encoding::BINARY, str.encode('BINARY').encoding)
347
- end
348
-
349
- def test_non_ascii_str_eucjp_to_binary
350
- str = non_ascii_str_enc_eucjp
351
- assert_raise(Encoding::UndefinedConversionError) { str.encode('BINARY') }
352
- end
353
-
354
- def test_ascii_str_eucjp_to_utf8
355
- str = ascii_str_enc_eucjp
356
- assert_raise(Encoding::ConverterNotFoundError){ str.encode('UTF_8') }
357
- end
358
-
359
- def test_non_ascii_str_eucjp_to_utf8
360
- str = non_ascii_str_enc_eucjp
361
- assert_raise(Encoding::ConverterNotFoundError) { str.encode('UTF_8') }
362
- end
363
-
364
- def test_ascii_str_eucjp_to_eucjp
365
- str = ascii_str_enc_eucjp
366
- assert_equal(Encoding::EUCJP, str.encode('EUCJP').encoding)
367
- end
368
-
369
- def test_non_ascii_str_eucjp_to_eucjp
370
- str = non_ascii_str_enc_eucjp
371
- assert_equal(Encoding::EUCJP, str.encode('EUCJP').encoding)
372
- end
373
-
374
- def test_ascii_str_eucjp_to_sjis
375
- str = ascii_str_enc_eucjp
376
- assert_equal(Encoding::SJIS, str.encode('SJIS').encoding)
377
- end
378
-
379
- def test_non_ascii_str_eucjp_to_sjis
380
- str = non_ascii_str_enc_eucjp
381
- assert_equal(Encoding::SJIS, str.encode('SJIS').encoding)
382
- end
383
-
384
- def test_ascii_str_eucjp_to_utf16le
385
- str = ascii_str_enc_eucjp
386
- assert_raise(Encoding::ConverterNotFoundError){ str.encode('UTF_16LE') }
387
- end
388
-
389
- def test_non_ascii_str_eucjp_to_utf16le
390
- str = non_ascii_str_enc_eucjp
391
- assert_raise(Encoding::ConverterNotFoundError) { str.encode('UTF_16LE') }
392
- end
393
-
394
- def test_ascii_str_eucjp_to_utf16be
395
- str = ascii_str_enc_eucjp
396
- assert_raise(Encoding::ConverterNotFoundError){ str.encode('UTF_16BE') }
397
- end
398
-
399
- def test_non_ascii_str_eucjp_to_utf16be
400
- str = non_ascii_str_enc_eucjp
401
- assert_raise(Encoding::ConverterNotFoundError) { str.encode('UTF_16BE') }
402
- end
403
-
404
- def test_ascii_str_sjis_to_ascii
405
- str = ascii_str_enc_sjis
406
- assert_equal(Encoding::ASCII, str.encode('ASCII').encoding)
407
- end
408
-
409
- def test_non_ascii_str_sjis_to_ascii
410
- str = non_ascii_str_enc_sjis
411
- assert_raise(Encoding::UndefinedConversionError) { str.encode('ASCII') }
412
- end
413
-
414
- def test_ascii_str_sjis_to_binary
415
- str = ascii_str_enc_sjis
416
- assert_equal(Encoding::BINARY, str.encode('BINARY').encoding)
417
- end
418
-
419
- def test_non_ascii_str_sjis_to_binary
420
- str = non_ascii_str_enc_sjis
421
- assert_raise(Encoding::UndefinedConversionError) { str.encode('BINARY') }
422
- end
423
-
424
- def test_ascii_str_sjis_to_utf8
425
- str = ascii_str_enc_sjis
426
- assert_raise(Encoding::ConverterNotFoundError){ str.encode('UTF_8') }
427
- end
428
-
429
- def test_non_ascii_str_sjis_to_utf8
430
- str = non_ascii_str_enc_sjis
431
- assert_raise(Encoding::ConverterNotFoundError) { str.encode('UTF_8') }
432
- end
433
-
434
- def test_ascii_str_sjis_to_eucjp
435
- str = ascii_str_enc_sjis
436
- assert_equal(Encoding::EUCJP, str.encode('EUCJP').encoding)
437
- end
438
-
439
- def test_non_ascii_str_sjis_to_eucjp
440
- str = non_ascii_str_enc_sjis
441
- assert_equal(Encoding::EUCJP, str.encode('EUCJP').encoding)
442
- end
443
-
444
- def test_ascii_str_sjis_to_sjis
445
- str = ascii_str_enc_sjis
446
- assert_equal(Encoding::SJIS, str.encode('SJIS').encoding)
447
- end
448
-
449
- def test_non_ascii_str_sjis_to_sjis
450
- str = non_ascii_str_enc_sjis
451
- assert_equal(Encoding::SJIS, str.encode('SJIS').encoding)
452
- end
453
-
454
- def test_ascii_str_sjis_to_utf16le
455
- str = ascii_str_enc_sjis
456
- assert_raise(Encoding::ConverterNotFoundError){ str.encode('UTF_16LE') }
457
- end
458
-
459
- def test_non_ascii_str_sjis_to_utf16le
460
- str = non_ascii_str_enc_sjis
461
- assert_raise(Encoding::ConverterNotFoundError) { str.encode('UTF_16LE') }
462
- end
463
-
464
- def test_ascii_str_sjis_to_utf16be
465
- str = ascii_str_enc_sjis
466
- assert_raise(Encoding::ConverterNotFoundError){ str.encode('UTF_16BE') }
467
- end
468
-
469
- def test_non_ascii_str_sjis_to_utf16be
470
- str = non_ascii_str_enc_sjis
471
- assert_raise(Encoding::ConverterNotFoundError) { str.encode('UTF_16BE') }
472
- end
473
-
474
- def test_ascii_str_utf16le_to_ascii
475
- str = ascii_str_enc_utf16le
476
- assert_equal(Encoding::ASCII, str.encode('ASCII').encoding)
477
- end
478
-
479
- def test_non_ascii_str_utf16le_to_ascii
480
- str = non_ascii_str_enc_utf16le
481
- assert_raise(Encoding::UndefinedConversionError) { str.encode('ASCII') }
482
- end
483
-
484
- def test_ascii_str_utf16le_to_binary
485
- str = ascii_str_enc_utf16le
486
- assert_equal(Encoding::BINARY, str.encode('BINARY').encoding)
487
- end
488
-
489
- def test_non_ascii_str_utf16le_to_binary
490
- str = non_ascii_str_enc_utf16le
491
- assert_raise(Encoding::UndefinedConversionError) { str.encode('BINARY') }
492
- end
493
-
494
- def test_ascii_str_utf16le_to_utf8
495
- str = ascii_str_enc_utf16le
496
- assert_raise(Encoding::ConverterNotFoundError){ str.encode('UTF_8') }
497
- end
498
-
499
- def test_non_ascii_str_utf16le_to_utf8
500
- str = non_ascii_str_enc_utf16le
501
- assert_raise(Encoding::ConverterNotFoundError) { str.encode('UTF_8') }
502
- end
503
-
504
- def test_ascii_str_utf16le_to_eucjp
505
- str = ascii_str_enc_utf16le
506
- assert_equal(Encoding::EUCJP, str.encode('EUCJP').encoding)
507
- end
508
-
509
- def test_non_ascii_str_utf16le_to_eucjp
510
- str = non_ascii_str_enc_utf16le
511
- assert_equal(Encoding::EUCJP, str.encode('EUCJP').encoding)
512
- end
513
-
514
- def test_ascii_str_utf16le_to_sjis
515
- str = ascii_str_enc_utf16le
516
- assert_equal(Encoding::SJIS, str.encode('SJIS').encoding)
517
- end
518
-
519
- def test_non_ascii_str_utf16le_to_sjis
520
- str = non_ascii_str_enc_utf16le
521
- assert_equal(Encoding::SJIS, str.encode('SJIS').encoding)
522
- end
523
-
524
- def test_ascii_str_utf16le_to_utf16le
525
- str = ascii_str_enc_utf16le
526
- assert_raise(Encoding::ConverterNotFoundError){ str.encode('UTF_16LE') }
527
- end
528
-
529
- def test_non_ascii_str_utf16le_to_utf16le
530
- str = non_ascii_str_enc_utf16le
531
- assert_raise(Encoding::ConverterNotFoundError) { str.encode('UTF_16LE') }
532
- end
533
-
534
- def test_ascii_str_utf16le_to_utf16be
535
- str = ascii_str_enc_utf16le
536
- assert_raise(Encoding::ConverterNotFoundError){ str.encode('UTF_16BE') }
537
- end
538
-
539
- def test_non_ascii_str_utf16le_to_utf16be
540
- str = non_ascii_str_enc_utf16le
541
- assert_raise(Encoding::ConverterNotFoundError) { str.encode('UTF_16BE') }
542
- end
543
-
544
- def test_ascii_str_utf16be_to_ascii
545
- str = ascii_str_enc_utf16be
546
- assert_equal(Encoding::ASCII, str.encode('ASCII').encoding)
547
- end
548
-
549
- def test_non_ascii_str_utf16be_to_ascii
550
- str = non_ascii_str_enc_utf16be
551
- assert_raise(Encoding::UndefinedConversionError) { str.encode('ASCII') }
552
- end
553
-
554
- def test_ascii_str_utf16be_to_binary
555
- str = ascii_str_enc_utf16be
556
- assert_equal(Encoding::BINARY, str.encode('BINARY').encoding)
557
- end
558
-
559
- def test_non_ascii_str_utf16be_to_binary
560
- str = non_ascii_str_enc_utf16be
561
- assert_raise(Encoding::UndefinedConversionError) { str.encode('BINARY') }
562
- end
563
-
564
- def test_ascii_str_utf16be_to_utf8
565
- str = ascii_str_enc_utf16be
566
- assert_raise(Encoding::ConverterNotFoundError){ str.encode('UTF_8') }
567
- end
568
-
569
- def test_non_ascii_str_utf16be_to_utf8
570
- str = non_ascii_str_enc_utf16be
571
- assert_raise(Encoding::ConverterNotFoundError) { str.encode('UTF_8') }
572
- end
573
-
574
- def test_ascii_str_utf16be_to_eucjp
575
- str = ascii_str_enc_utf16be
576
- assert_equal(Encoding::EUCJP, str.encode('EUCJP').encoding)
577
- end
578
-
579
- def test_non_ascii_str_utf16be_to_eucjp
580
- str = non_ascii_str_enc_utf16be
581
- assert_equal(Encoding::EUCJP, str.encode('EUCJP').encoding)
582
- end
583
-
584
- def test_ascii_str_utf16be_to_sjis
585
- str = ascii_str_enc_utf16be
586
- assert_equal(Encoding::SJIS, str.encode('SJIS').encoding)
587
- end
588
-
589
- def test_non_ascii_str_utf16be_to_sjis
590
- str = non_ascii_str_enc_utf16be
591
- assert_equal(Encoding::SJIS, str.encode('SJIS').encoding)
592
- end
593
-
594
- def test_ascii_str_utf16be_to_utf16le
595
- str = ascii_str_enc_utf16be
596
- assert_raise(Encoding::ConverterNotFoundError){ str.encode('UTF_16LE') }
597
- end
598
-
599
- def test_non_ascii_str_utf16be_to_utf16le
600
- str = non_ascii_str_enc_utf16be
601
- assert_raise(Encoding::ConverterNotFoundError) { str.encode('UTF_16LE') }
602
- end
603
-
604
- def test_ascii_str_utf16be_to_utf16be
605
- str = ascii_str_enc_utf16be
606
- assert_raise(Encoding::ConverterNotFoundError){ str.encode('UTF_16BE') }
607
- end
608
-
609
- def test_non_ascii_str_utf16be_to_utf16be
610
- str = non_ascii_str_enc_utf16be
611
- assert_raise(Encoding::ConverterNotFoundError) { str.encode('UTF_16BE') }
612
- end
613
-
614
- def test_ord
615
- a = 'a'
616
- abc = 'abc'
617
- assert_equal(97, a.ord, "#{a}.ord faild\n")
618
- assert_equal(97, abc.ord, "#{abc}.ord faild\n")
619
- end
620
-
621
- def test_force_encodig
622
- str = 'あいう'
623
- org_dump = unpack_record(str)
624
- asc8_dump = unpack_record(str.force_encoding('ASCII-8BIT'))
625
- assert_equal(org_dump, asc8_dump)
626
- end
627
- end
1
+ # -*- coding: utf-8 -*-
2
+ require 'helper'
3
+ require 'nkf'
4
+
5
+ class TC_Compatibility < Test::Unit::TestCase
6
+ def test_ord
7
+ a = 'a'
8
+ abc = 'abc'
9
+ assert_equal(97, a.ord, "#{a}.ord faild\n")
10
+ assert_equal(97, abc.ord, "#{abc}.ord faild\n")
11
+ end
12
+ end