1 2 17 18 19 20 package org.apache.poi.hssf.record; 21 22 23 import junit.framework.TestCase; 24 25 33 public class TestBarRecord 34 extends TestCase 35 { 36 byte[] data = new byte[] { 37 (byte)0x00,(byte)0x00, (byte)0x96,(byte)0x00, (byte)0x00,(byte)0x00 }; 41 42 public TestBarRecord(String name) 43 { 44 super(name); 45 } 46 47 public void testLoad() 48 throws Exception 49 { 50 51 BarRecord record = new BarRecord((short)0x1017, (short)data.length, data); 52 assertEquals( 0, record.getBarSpace()); 53 assertEquals( 0x96, record.getCategorySpace()); 54 assertEquals( 0, record.getFormatFlags()); 55 assertEquals( false, record.isHorizontal() ); 56 assertEquals( false, record.isStacked() ); 57 assertEquals( false, record.isDisplayAsPercentage() ); 58 assertEquals( false, record.isShadow() ); 59 60 61 assertEquals( 10, record.getRecordSize() ); 62 63 record.validateSid((short)0x1017); 64 } 65 66 public void testStore() 67 { 68 BarRecord record = new BarRecord(); 69 record.setBarSpace( (short)0 ); 70 record.setCategorySpace( (short)0x96 ); 71 record.setHorizontal( false ); 72 record.setStacked( false ); 73 record.setDisplayAsPercentage( false ); 74 record.setShadow( false ); 75 76 77 byte [] recordBytes = record.serialize(); 78 assertEquals(recordBytes.length - 4, data.length); 79 for (int i = 0; i < data.length; i++) 80 assertEquals("At offset " + i, data[i], recordBytes[i+4]); 81 } 82 } 83 | Popular Tags |