1 2 17 18 19 package org.apache.poi.hssf.record; 20 21 import junit.framework.TestCase; 22 23 30 public class TestBoundSheetRecord 31 extends TestCase 32 { 33 public TestBoundSheetRecord( String s ) 34 { 35 super( s ); 36 } 37 38 public void testRecordLength() 39 throws Exception 40 { 41 BoundSheetRecord record = new BoundSheetRecord(); 42 record.setCompressedUnicodeFlag((byte)0x00); 43 record.setSheetname("Sheet1"); 44 record.setSheetnameLength((byte)6); 45 46 assertEquals(" 2 + 2 + 4 + 2 + 1 + 1 + len(str)", 18, record.getRecordSize()); 47 } 48 49 public void testWideRecordLength() 50 throws Exception 51 { 52 BoundSheetRecord record = new BoundSheetRecord(); 53 record.setCompressedUnicodeFlag((byte)0x01); 54 record.setSheetname("Sheet1"); 55 record.setSheetnameLength((byte)6); 56 57 assertEquals(" 2 + 2 + 4 + 2 + 1 + 1 + len(str) * 2", 24, record.getRecordSize()); 58 } 59 60 public void testName() { 61 BoundSheetRecord record = new BoundSheetRecord(); 62 record.setSheetname("1234567890223456789032345678904"); 63 assertTrue("Success", true); 64 try { 65 record.setSheetname("12345678902234567890323456789042"); 66 assertTrue("Should have thrown IllegalArgumentException, but didnt", false); 67 } catch (IllegalArgumentException e) { 68 assertTrue("succefully threw exception",true); 69 } 70 71 try { 72 record.setSheetname("s//*s"); 73 assertTrue("Should have thrown IllegalArgumentException, but didnt", false); 74 } catch (IllegalArgumentException e) { 75 assertTrue("succefully threw exception",true); 76 } 77 78 } 79 80 } 81 | Popular Tags |