test/test_workbook.rb in writeexcel-0.6.4 vs test/test_workbook.rb in writeexcel-0.6.5
- old
+ new
@@ -46,54 +46,59 @@
assert_raise(RuntimeError, "set_tempdir() doesn't raise invalid dir:#{dir}."){
@workbook.set_tempdir(dir)
}
end
-=begin
-#
-# Comment out because Workbook#check_sheetname was set to private method.
-#
def test_check_sheetname
- valids = valid_sheetname
- invalids = invalid_sheetname
worksheet1 = @workbook.add_worksheet # implicit name 'Sheet1'
worksheet2 = @workbook.add_worksheet # implicit name 'Sheet2'
- worksheet3 = @workbook.add_worksheet 'Sheet3' # implicit name 'Sheet3'
- worksheet1 = @workbook.add_worksheet 'Sheetz' # implicit name 'Sheetz'
+ worksheet3 = @workbook.add_worksheet 'Sheet3' # explicit name 'Sheet3'
+ worksheet4 = @workbook.add_worksheet 'Sheetz' # explicit name 'Sheetz'
- valids.each do |test|
+ valid_sheetnames.each do |test|
target = test[0]
sheetname = test[1]
caption = test[2]
- assert_nothing_raised { @workbook.check_sheetname(sheetname) }
+ assert_nothing_raised { @workbook.add_worksheet(sheetname) }
end
- invalids.each do |test|
+
+ invalid_sheetnames.each do |test|
target = test[0]
sheetname = test[1]
caption = test[2]
assert_raise(RuntimeError, "sheetname: #{sheetname}") {
- @workbook.check_sheetname(sheetname)
+ @workbook.add_worksheet(sheetname)
}
end
end
-=end
+ def test_check_sheetname_utf8_only
+ ['Лист 1', 'Лист 2', 'Лист 3'].each do |sheetname|
+ assert_nothing_raised { @workbook.add_worksheet(sheetname) }
+ end
+ end
+
+ def test_check_unicode_bytes_even
+ assert_nothing_raised(RuntimeError){ @workbook.add_worksheet('ab', 1)}
+ assert_raise(RuntimeError){ @workbook.add_worksheet('abc', 1)}
+ end
+
def test_raise_set_compatibility_after_sheet_creation
@workbook.add_worksheet
assert_raise(RuntimeError) { @workbook.compatibility_mode }
end
- def valid_sheetname
+ def valid_sheetnames
[
# Tests for valid names
[ 'PASS', nil, 'No worksheet name' ],
[ 'PASS', '', 'Blank worksheet name' ],
[ 'PASS', 'Sheet10', 'Valid worksheet name' ],
[ 'PASS', 'a' * 31, 'Valid 31 char name' ]
]
end
- def invalid_sheetname
+ def invalid_sheetnames
[
# Tests for invalid names
[ 'FAIL', 'Sheet1', 'Caught duplicate name' ],
[ 'FAIL', 'Sheet2', 'Caught duplicate name' ],
[ 'FAIL', 'Sheet3', 'Caught duplicate name' ],