1 2 17 18 19 20 package org.apache.poi.hssf.record; 21 22 23 import junit.framework.TestCase; 24 25 33 public class TestSeriesTextRecord 34 extends TestCase 35 { 36 byte[] data = new byte[] { 37 (byte)0x00,(byte)0x00,(byte)0x0C,(byte)0x01,(byte)0x56,(byte)0x00,(byte)0x61,(byte)0x00,(byte)0x6C,(byte)0x00,(byte)0x75,(byte)0x00,(byte)0x65,(byte)0x00,(byte)0x20,(byte)0x00,(byte)0x4E,(byte)0x00,(byte)0x75,(byte)0x00,(byte)0x6D,(byte)0x00,(byte)0x62,(byte)0x00,(byte)0x65,(byte)0x00,(byte)0x72,(byte)0x00 38 }; 39 40 public TestSeriesTextRecord(String name) 41 { 42 super(name); 43 } 44 45 public void testLoad() 46 throws Exception 47 { 48 SeriesTextRecord record = new SeriesTextRecord((short)0x100d, (short)data.length, data); 49 50 51 assertEquals( (short)0, record.getId()); 52 53 assertEquals( (byte)0x0C, record.getTextLength()); 54 55 assertEquals( (byte)0x01, record.getUndocumented()); 56 57 assertEquals( "Value Number", record.getText()); 58 59 60 assertEquals( 32, record.getRecordSize() ); 61 62 record.validateSid((short)0x100d); 63 } 64 65 public void testStore() 66 { 67 SeriesTextRecord record = new SeriesTextRecord(); 68 69 70 71 record.setId( (short)0 ); 72 73 record.setTextLength( (byte)0x0C ); 74 75 record.setUndocumented( (byte)0x01 ); 76 77 record.setText( "Value Number" ); 78 79 80 byte [] recordBytes = record.serialize(); 81 assertEquals(recordBytes.length - 4, data.length); 82 for (int i = 0; i < data.length; i++) 83 assertEquals("At offset " + i, data[i], recordBytes[i+4]); 84 } 85 } 86 | Popular Tags |